Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test(testName = "defaultName", dataProvider="tests")
- public void testLogin( int num, String reportName )
- {
- System.out.println("Starting " + num + ": " + reportName);
- changeTestName("Test" + num);
- }
- import java.lang.reflect.Method;
- import org.testng.ITest;
- import org.testng.annotations.Test;
- import org.testng.annotations.BeforeMethod;
- public class MyTestClass implements ITest {
- @Test(dataProvider = "/* yourDataProvider */")
- public void myTestMethod() {
- //Test method body
- }
- @BeforeMethod(alwaysRun = true)
- public void setTestName(Method method, Object[] row) {
- //You have the test data received through dataProvider delivered here in row
- String name = resolveTestName(row);
- testName.set(name);
- }
- @Override
- public String getTestName() {
- return testName.get();
- }
- private ThreadLocal<String> testName = new ThreadLocal<>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement