2023-05-31

How do I implement timeOuts in TestNG? They don't appear to be working

@Test(dataProvider="TestDataSets", dataProviderClass = TestData.class, groups = { "SmokeTests", "Regression" }, timeOut = 120000)
public void MyTestCase(String scenario, String formName) throws Exception {

Am I implementing the timeOut incorrectly? This should timeout after 120 seconds, correct? Some of my test cases run too long and should be terminating at 120 seconds but they are never terminated by TestNG.

I'm running Java 17 with TestNG 7.8.0

Upon further investigation TestNG did determine that my test case hit the timeOut:

[ERROR] testCaseClassFile.methodName » ThreadTimeout Method tests.testCaseClassFile.methodName() didn't finish within the time-out 120000

Apparently it hit the timeOut and kept on going. The TestNG documentation made me think that it would stop execution:

Section 5.11.2 of the TestNG documentation states,

Additionally, a time-out of ten seconds guarantees that none of the threads will block on this thread forever.

Assuming the documentation is in fact true then this would seem like a bug to me.



No comments:

Post a Comment