I would like to get argument names and their values from @Test in TestNG. These arguments are provided by @DataProvider. Normally, I can store it in variables of class by its not good idea when i would like to run test parallel. Here is my code:
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class TestHomePage{
@BeforeMethod(alwaysRun = true)
public void setup(Method method) throws Exception {
System.out.println("INFO ====setup===:" + method.getName());
// how can I get parameters and value from @Test?
//ex: sLogin="notLogin";sLike=""
}
@AfterMethod()
public void tearnDown(Method method) {
System.out.println("INFO ====tearnDown===:" + method.getName());
// how can I get parameters and value from @Test?
}
@DataProvider(name = "likedata", parallel = true)
public Object[][] likeDataprovider() throws Exception {
return new Object[][] { { "notLogin", "" }, { "loggedIn", "notLike" }, { "loggedIn", "liked" } };
}
@Test(dataProvider = "likedata")
public void verifyLikeFunction(String sLogin, String sLike, Method method) throws Exception {
// Test
}
}
Any one can help me?
Thanks.