I have a particular problem regarding TestNG and annotations
I have created a factory with dataprovider which has 3 values
And I want my testsuite.xml to run this code and create in @BeforeGroups all 3 instances from dataprovider(currently it creates only 1). Is it at least possible?
public class FactroryClass {
@factory(dataprovider =data)
public Object[] createTest(String code) {
return new Object[]{new TestClass(code)};
}
public class TestClass{
public TestClass(String code) {
this.code = code;
}
@BeforeGroups(groups = "prepare-data", dependsOnGroups = "prepare--files")
public void setUp() throws Exception {
testMethod1(String a){
//some actions with a which is set from dataprovider}
}
@Test(dependsOnGroups = "execute")
public void test() throws Exception {
//actions to verify results in the end
}
}
public class PrepareFile {
@Test(groups = "prepare--files", invocationCount = 1)
public void test() throws Exception {
//we prepare files here
}
}
public class Run {
@Test(groups = "execute", dependsOnGroups = "prepare-data", invocationCount = 1, alwaysRun = true)
public void test() throws Exception {
//Run here
}
Aucun commentaire:
Enregistrer un commentaire