I am working on Test integration and using Testing for that, Here I need to run sequence of test cases with multiple test data. Here test cases has dependencies between each other.
public class MyTestCase extends ISIntegrationTest {
TestBean testbean;
@Factory(dataProvider = "beanProvider")
public MyTestCase(TestBean testbean) {
this.testbean = testbean;
}
@DataProvider(name = "beanProvider")
public static TestBean[][] beanProvider() {
return new TestBean[][] { { new TestBean("type1") },
{ new TestBean("type2") } };
}
@BeforeTest(alwaysRun = true)
public void testInit() throws Exception {
}
@AfterTest(alwaysRun = true)
public void atEnd() throws Exception {
}
@Test(alwaysRun = true, description = "test1")
public void test1() {
System.out.println("test1 : " + testbean.type);
}
@Test(groups = "wso2.is", description = "test2", dependsOnMethods = "test1")
public void test2() throws Exception {
System.out.println("test2 : " + testbean.type);
}
@Test(groups = "wso2.is", description = "test3", dependsOnMethods = "test2")
public void test3() throws Exception {
System.out.println("test3 : " + testbean.type);
}
static class TestBean{
String type;
TestBean(String type){
this.type = type;
}
}
}
Here I need to run test1, test2 and test3 as a sequence with provide data element of passing array. I am expecting output as below according to above sample.
test1 : type1 test2 : type1 test3 : type1 test1 : type2 test2 : type2 test3 : type2
But I am getting following output
test1 : type1 test1 : type2 test2 : type1 test2 : type2 test3 : type1 test3 : type2
Is there any way to overcome this issue ?