Closed juherr closed 7 years ago
The below sample should be pretty straight forward to use to get this done and in my opinion doesn't need anything extra from TestNG side.
import org.testng.ITestResult;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
public class Issue1061Sample {
private final long timeout;
private final long waitTime;
@DataProvider
public static Object[][] dp() {
return new Object[][]{
new Object[]{1_000, 2_000},
new Object[]{3_000, 6_000}
};
}
@Factory(dataProvider = "dp")
public Issue1061Sample(long timeout, long waitTime) {
this.timeout = timeout;
this.waitTime = waitTime;
}
@BeforeMethod
public void setup(ITestResult result) {
result.getMethod().setTimeOut(timeout);
}
@Test
public void test() throws InterruptedException {
Thread.sleep(waitTime);
}
}
But this sample will only work properly from TestNG 6.13 Fix for #1493 needs to be available and PR #1550 needs to be merged. Both of this would be available only in TestNG 6.13 or above.
From: http://stackoverflow.com/q/37722712/4234729