0

Usually I usethe annotation @FixMethodOrder(MethodSorters.NAME_ASCENDING) and my tests start by test001_nametest1, test002_nametest2, ..

With this method adding a test between existing test is problematic (because you have to rename all test after).

Is there a way to execute all junit test in the written order ?

Youssouf Maiga
  • 6,701
  • 7
  • 26
  • 42
  • 1
    The question you want to be asking your is "why?". What's your reasoning for doing this? – tddmonkey Mar 13 '17 at 11:14
  • In my design, I have dependencies between tests. Some creates data in database that are consumed by others so the order is important. – Youssouf Maiga Mar 13 '17 at 11:30
  • Check out the options posted in the similar question: https://stackoverflow.com/questions/3693626/how-to-run-test-methods-in-specific-order-in-junit4 – default locale Mar 13 '17 at 12:27
  • Generally your tests should be independent of each other. – cjstehno Mar 13 '17 at 12:38
  • Instead of relying on order, have each of your tests ensure they have the right data independently. – tddmonkey Mar 13 '17 at 14:42
  • Possible duplicate of [How to run test methods in specific order in JUnit4?](http://stackoverflow.com/questions/3693626/how-to-run-test-methods-in-specific-order-in-junit4) – Sasha Shpota Mar 13 '17 at 21:00

0 Answers0