We are setting up a new step on our build server to trigger E2E testing, as we did for UT.

Some E2E make changes to the test database, so we encounter problems because the tests are not executed one after the other but are multi-threaded, thus the results of the test are not stable.

Context :

  • The database is created from scratch when the test project is started;
  • modifications are done by a test is removed by the same test;

Is there a way to make tests run on a single thread, one by one? Not only the tests within a class but with all the tests of the test project?


1 Answer 1


To run tests one by one, you could use a test runner that allows you to set up a test queue or test order, such as JUnit or TestNG. You can specify the order of tests to be run in the XML configuration file for JUnit or by using the @Test(dependsOnMethods={"testMethod1"}) attribute in TestNG.

You can also create a test harness that manages the test execution order and handles setup and teardown of the database. This approach requires more effort but gives you more control over the test environment and allows you to better manage the test data.

In either case, it is recommended to isolate the tests and run each test in its own transaction, with the transaction rolled back after each test, to ensure that the test data is not persisted between tests. This approach will also help to prevent data corruption caused by tests interfering with each other.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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