I have two classes inheriting from a MyTestData
class which gets testdata from excel depending on the parameter passed to it.
public class A1 extends MyTestData {
public A1() {
super("A1");
}
@Test
//Methods
--
public class A2 extends MyTestData {
public A2() {
super("A2");
}
@Test
//Methods
--
public class MyTestData {
public MyTestData(String test) {
System.out.println("test data parameter is " + test);
switch (test) {
case "A1":
A1_data();
break;
case "A2":
A2_data();
break;
}
}
private void A1_data() {
//Fetch data from excel
}
private void A2_data() {
//Fetch data from excel
}
I have these two classes in a testng.xml file
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
<test name="Test A1">
<classes>
<class name="mypackage.A1"/>
</classes>
</test>
<test name="Test A2">
<classes>
<class name="mypackage.A2"/>
</classes>
</test>
</suite>
But when I run the xml file I get this output on console as soon as execution starts:
test data parameter is A1
test data parameter is A2
And the test A1 runs with data of A2. Why is this happening and how can I prevent this? I want A2 to start after A1 has completed execution.