Running JUnit test classes from another JUnit test class
- by Dr. Monkey
I have two classes that I am testing (let's call them ClassA and ClassB). Each has its own JUnit test class (testClassA and testClassB respectively).
ClassA relies on ClassB for its normal functioning, so I want to make sure ClassB passes its tests before running testClassA (otherwise the results from testClassA would be meaningless).
What is the best way to do this? In this case it is for an assignment so I need to keep it to the two specified test classes if possible.
Can/should I throw an exception from testClassA if testClassB's tests aren't all passed? This would require testClassB to run invisibly and just report its success/failure to testClassA, rather than to the GUI (via JUnit).
I am using Eclipse and JUnit 4.8.1