import org.testng.IHookCallBack;
import org.testng.IHookable;
import org.testng.ITestResult;
import org.testng.SkipException;
import java.util.Optional;
public class TestBase implements IHookable {
@Override
public void run(IHookCallBack callBack, ITestResult testResult) {
Object[] parameters = Optional.ofNullable(testResult.getParameters()).orElse(new Object[0]);
if (parameters.length == 0) {
callBack.runTestMethod(testResult);
return;
}
boolean flag = Boolean.parseBoolean(parameters[0].toString());
if (flag) {
callBack.runTestMethod(testResult);
} else {
throw new SkipException("Skipping test " + testResult.getMethod().getMethodName());
}
}
}
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class MyTestClass extends TestBase {
@Test(dataProvider = "data")
public void test(boolean flag) {
System.err.println("Hello World");
}
@DataProvider
public Object[][] data() {
return new Object[][]{
{true},
{false}
};
}
}
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/849a054b-b904-43e2-8651-681a5fbb6bben%40googlegroups.com.