2

I need to execute tests in specific order (Login, Go to menu, Open form, do several tests). Back in 2014 we used TestNg method dependency. This is very important feature for end-to-end testing. JUnit 5 has only @FixMethodOrder which is less powerful. I like JUnit more and on the other hand I'm missing some JUnit features in TestNg, for instance @Rule. I there some workaround for method dependency in JUnit or should I use TestNg again?

Sobik
  • 632
  • 3
  • 8
  • 14
  • I think you should change test design of your tests. Make steps (login, go to menu,etc..) and use their in tests. Tests should not depend on the order of execution. JUnit5 very good testing framework and it is developing rapidly and have big community. – Sergey Apr 24 '19 at 16:46
  • 2
    That's true for unit and sometimes for integration tests. End-to-end tests with Selenium or other framework is rather scenario testing with desired specific order of steps. Example: Edit user profile, clear fist and last name, try to submit, check for errors, enter last name, check there is still error for missing first name, enter first name, submit, check no error, ... It would be very tedious to include basic steps (login, ....) and add all previous steps to each test. But e2e browser testing is very slow compared to unit tests therefore main reason fot test dependency is speed of tests. – Sobik Apr 26 '19 at 22:23
  • Yes, I agree, a certain order of test execution can reduce the time it takes to complete a test suite. I also looked for a way to perform tests in a specific order, but to optimize the overall runtime of the test suite. You can see my question here: https://stackoverflow.com/q/55632208/1477873 – Sergey Apr 30 '19 at 07:07

1 Answers1

2

As you have already said you could use @FixMethodOrder annotation or call one test from another (which really shouldn't be an option).

Anyways, I'd stick with TestNG, because as far as I know its idea is to make JUnit tests easier and to improve some functionalities (NG stands for New Generation).

lmilunovic
  • 191
  • 1
  • 10