I have test cases which have priority tags on them. Let's say 30 cases run sequentially one by one. But this does not allow me to attach a retry listener to my cases due to tests being dependent on each other. If test 25 fails, all tests in the test class should be retried which seems to be impossible.

For a new project, I abandoned this method and removed the priority tag to make each test method independent. Now, I can use a retry listener which runs the individual test again after it fails.

Which method seems to be a better approach? What may be pros and cons of both approaches? I can't really find example test classes online to compare with my tests and I am the only automation dev in my company.

  • 1
    Having test cases be dependent on one another is a definite smell, but it's unclear why you needed to do that to begin with. – jonrsharpe Jul 31 '19 at 7:24
  • Hi, it was an intuitive way of doing things when I first started automation. I was wondering if other people were doing the same thing. – user38046 Jul 31 '19 at 7:25
  • 1
    "it was an intuitive way ... when I first started .. I was wondering if other people were doing the same thing" That's why mastery passes through the Shu Ha Ri Ku phases. – João Farias Jul 31 '19 at 11:31

To be idealistic, isolated tests are the best. That makes test suite cleaner and the point of failure is also separated and you can also run them in parallel. In this approach, there would be an overhead of running the setup and tear-down for all the tests, but this cost definitely pays off against the complex tests.

If you really want to set priority, setting up dependency is a preferred way than setting up priority. I vote for making the tests isolate. This really helps in the long run, making the test suite clean, maintainable and readable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy