TestNG: Threading Questions

When will TestNG run tests in the same thread?

The quick answer is, when test methods depend on each other. The important thing to note here is that it is when @Test annotated methods depend on each other.

One way to solve this problem is to declare that the test methods depend on each other, thus forcing TestNG to run them in the same thread, but that’s obviously tedious and also not semantically correct (they don’t really depend on each other).

Announcing TestNG 5.1: making testing easier, one thread at a time

Can you force tests to run in only one thread?

The @Test(sequential=”true”) attribute on a class will cause all the test methods in that class to run in a single thread.

Note that the threads used to run your sequential classes are picked from the common pool, so you might have to increase its size (some of the workers will take longer before being returned to the pool since they now run entire classes).

TestNG-Users Mailing List

One Response to “TestNG: Threading Questions”

  1. […] TestNG: Threading Questions […]

Leave a Reply