1

1. Should all automated test modules connected to each other ?

  • Like, when I have a @Test module for Registration, after executing that module, can I connect this test to @Test Login, @Test Login to @Test Edit Profile? In my current setup, Registration, Login, Forgot Password and Edit Profile modules are all executed at once.

2. Is it a good practice to do that?

3. Or just leave each @Test module separate to each other?

  • I haven't dug deep into TestNG. I've only used @Test, @BeforeTest, @AfterTest annotations for now. I hope you'll shed some light. Thanks Guys. I'm using Selenium Webdriver (JAVA) btw with @TestNG
2

Good practice is that each test is autonomous. That is to say, no test relies on the output of another.

The simple reason being is that if one test fails, you can re-run just that one test and resolve the issue. If they must be run in a specific sequence then you always have to run through all the tests to find out where the issue lies.

Consider the following four tests:

  1. Create a new account
  2. Edit account address
  3. Edit account password
  4. Add credit card to account

What happens when the credit card test fails? Was it because of an issue in adding the credit card or was it a byproduct of an error in an earlier test? And while debugging, you must run all four tests in sequence to check your work.

This also precludes running just test number 3 as a smoke test. You have to run both test 1 and 2, and it would be hard to put a limitation in the test to selectively prevent the running of test 4.

Now imagine you have 100 tests.. 200 tests... Every time you want to add/edit a test you have to run the whole gambit which will add up to huge amounts of down time while waiting to get to the test you want.

All that said, you can always do what you want and what works best for your situation.

2

Actually, the "no test relies on the output of another" rule of thumbs doesn't apply here, because you don't want to pass data between tests, but you want to create a dependency tree because your business makes tests X a nonsense if Y it not ok.

When using TestNG, you can annotate with dependsOnMethods to make a test run just if the another is green.

Good to notice that this pratices should only be cosidered when talking about end-to-end tests. On lower levels of tests, your modules should rely, during test, on mocks. They can be time-consuming, but them allow tests to be run in parallel easilly and migates this dependency problem.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.