1
votes

I have a testng factory creating test instances having single @Test method. With "parallel=instances" and thread-count = "10" specified in testng.xml, I expect @BeforeClass to execute in parallel. Whereas I see the @BeforeClass of other threads is blocked on execution till the current @BeforeClass execution is complete. i.e prints "In Before Class" in sequence with 2 second delay.

What am I missing here ?

Here is my test code -

@BeforeClass
public void beforeClass() throws InterruptedException{
    System.out.println("In Before Class ::: " + Thread.currentThread().getId());
    Thread.sleep(2000);
}


@Test
public void test(){
    System.out.println("In Test ::: " + Thread.currentThread().getId());
}

@AfterClass
public void afterClass(){
    System.out.println("In After Class ::: " + Thread.currentThread().getId());
}
1
Any update on this?Andrew Truett

1 Answers

1
votes

Try @BeforeClass(alwaysRun = true)