diff --git a/app/src/androidTest/java/com/example/househomey/EditItemFragmentTest.java b/app/src/androidTest/java/com/example/househomey/EditItemFragmentTest.java index 4184e17..80f8a94 100644 --- a/app/src/androidTest/java/com/example/househomey/EditItemFragmentTest.java +++ b/app/src/androidTest/java/com/example/househomey/EditItemFragmentTest.java @@ -48,7 +48,7 @@ public void navigateToEditItemFragment() throws Exception { .atPosition(0) .perform(click())); // Click on edit button - onView(withId(R.id.edit_button)).perform(scrollTo()); + waitFor(() -> onView(withId(R.id.edit_button)).perform(scrollTo())); onView(withId(R.id.edit_button)).perform(click()); } diff --git a/app/src/androidTest/java/com/example/househomey/SelectDeleteTest.java b/app/src/androidTest/java/com/example/househomey/SelectDeleteTest.java index eff3df0..00a1512 100644 --- a/app/src/androidTest/java/com/example/househomey/SelectDeleteTest.java +++ b/app/src/androidTest/java/com/example/househomey/SelectDeleteTest.java @@ -47,7 +47,7 @@ public void createData() throws Exception { database.addTestItem(mockData); database.addTestItem(mockData); database.addTestItem(mockData); - waitFor(() -> onView(withId(R.id.total_count_text)).check(matches(withText("3")))); + waitFor(() -> hasListLength(3)); } @Test diff --git a/app/src/androidTest/java/com/example/househomey/testUtils/TestHelpers.java b/app/src/androidTest/java/com/example/househomey/testUtils/TestHelpers.java index ad817d3..fdc5386 100644 --- a/app/src/androidTest/java/com/example/househomey/testUtils/TestHelpers.java +++ b/app/src/androidTest/java/com/example/househomey/testUtils/TestHelpers.java @@ -54,7 +54,7 @@ public static void waitFor(Runnable lambda) { try { lambda.run(); return; // Statement executed successfully, exit - } catch (Exception ignore) { + } catch (Throwable ignore) { } try { Thread.sleep(POLLING_INTERVAL); @@ -65,7 +65,7 @@ public static void waitFor(Runnable lambda) { // Retry one last time, otherwise error out with added description try { lambda.run(); - } catch (Exception e) { + } catch (Throwable e) { throw new AssertionError("Espresso statement did not succeed within the timeout. " + e.getMessage()); } }