Using priority in test cases with retry listener
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.
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.