I have an abstract class that extends the JUnit TestCase with related data
public abstract class AbstractTestClass extends TestCase
{
public ArrayList<TestDetails> testList;
}
I then have a test class that extends the abstract classes
public class TestClass extends AbstractTestClass
This is included in a test suite
@RunWith(Suite.class)
@Suite.SuiteClasses({
TestClass.class
})
public class TestSuite {
}
I then run the test suite from a runner class with a main function
public class TestRunner {
public static void main(String[] args) {
JUnitCore.runClasses(TestSuite.class);
}
}
My question is how do I access the testList data from within the runner class, i.e. if I wanted to print out the details of each element in the list from the main. The data is created dynamically (during the tests are being run)
One way out might be to declare the ArrayList Testlist as static and make the TestRunner class extend the AbstractTestCase class:
So now your AbstractTestCase class looks as below:
and your TestRunner class looks like:
Now you can access testList from the TestRunner. It may not the most elegant solution but it works.