1

In my test suite, out of 10, atleast 2 test failing every time but on running that method alone is not failing.how to handle this type of issue

As of now , I am doing with Thread.sleep to avoid more failures. How to do explicit wait

Arjun Govind
  • 41
  • 1
  • 6
  • Show your code. – mentallurg Jun 15 '19 at 10:17
  • @mentallurg If I run a particular method alone, it's running perfect.On running a whole suite only making some methods fail.Even the failed method in first run got passed in next attempts.I think its because of wait problem..cant get correct explicit wait..If I use implicitly it will pass all..I want something explicit kind of wait based on element's appearance as like in appium – Arjun Govind Jun 15 '19 at 10:27
  • Without seeing the code we can give you 1000 possible reasons that can explain this behaviour. That's why show the code. Then we can give more precise advice. – mentallurg Jun 15 '19 at 10:31
  • public void waitFor(ViewInteraction viewInteraction, ViewAssertion viewAssertion, long timeout) { PollingTimeoutIdler idler = new PollingTimeoutIdler(viewInteraction, viewAssertion, timeout); IdlingRegistry.getInstance().register(idler); viewInteraction.check(viewAssertion); IdlingRegistry.getInstance().unregister(idler); } – Arjun Govind Jun 15 '19 at 10:35
  • @mentallurg I am using the above code for explicit wait.But its not working properly I guess.How can I check that – Arjun Govind Jun 15 '19 at 10:35
  • How do you execute your tests? Where and how you define what is the sequence of the test execution? – mentallurg Jun 15 '19 at 10:38
  • Executing through Spoon task ( SpoonDebugAndroidTest) from terminal. and for order I am using @RunWith(AndroidJUnit4.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) these annotations. All my tests are independent too – Arjun Govind Jun 15 '19 at 10:51

1 Answers1

0

Disabling the animation will help to minimize most flaky fails.

To disable animations from mac terminal

adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0

For furthermore give proper sleep time and assertions

VIGNESH
  • 466
  • 6
  • 8