Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Independent tests

Why create atomic, independent tests?

A good practice in automation testing is that every test is completely independent of other tests.

Atomic tests:

  • do not rely on their order

  • have no dependencies between them, no shared variables

  • do not require any additional manual preparation

  • they are small, they should verify just one feature

Benefits of independent end-to-end test cases:

  • Easier debugging

  • Can be run in parallel

  • Easier team collaboration

Can I order tests?

Ordering tests is not a recommended practice, because end-to-end tests should be atomic (see above).

Example test case: register a new user --> login to an admin panel --> check if the user exists --> delete the user

You might be tempted to create one test for user registration and one for checking if the user is created. But all of these steps should be in one test only. You can't split it because one of the tests would need to wait until the first is finished. You won't be able to run the second test without running the first one, it will just lead to problems and so-called spaghetti between the tests.

Solution: simply create a single test with all of these steps, no dependencies, no problems 😄

That's why BugBug doesn't let you set a custom order for the main tests in a test suite or combine them into one run. It's better to duplicate the tests and use components to share steps between tests.

What about setup and cleanup?

If a suite needs a shared setup or cleanup, for example clearing test data after the run, use the suite's Before all / After all sections. Tests assigned there always run sequentially, before or after the main suite tests.

Keep the main suite tests independent of each other, so they can still run in parallel and be debugged one by one.

Last updated

Was this helpful?