I have created following relationship with object
public class Parent {
//Making API calls to get some data which can be used
//across multiple test classes
}
Then I'm inherting the Test classes as
public class Child1 extends Parent {
//I need data collected in Parent class
}
Again I have second class as
public class Child2 extends Parent {
//I also need the same data collected in Parent class
}
My TestNG
suite is as given below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="e2e-suite" verbose="1">
<test name="e2e tests" preserve-order="true">
<classes>
<class name="com.abc.test.Child1" />
<class name="com.abc.test.Child2" />
</classes>
</test>
</suite>
But , when I trigger the test suites , my Parent
class API data collection logic get invoked properly, I also get data that is direct available to first class which consumes it i.e Child1
But, for Child2
class , the Parent class logic isn't get invoked again (even I don't want it to execute again). The question is how the data that I collected in Parent class can be shared & persistent across other Child objects like Child2
.
Currently, I'm using static
Parent class Fields to share data. I'm looking for some Implementation which can allow me to store data from Parent class to another object which can be used across all Child Test objects (If any other better way to share data collected in parent class to later test classes is also fine for me)