Running JUnit test classes from another JUnit test class
Posted
by Dr. Monkey
on Stack Overflow
See other posts from Stack Overflow
or by Dr. Monkey
Published on 2010-03-22T03:48:00Z
Indexed on
2010/03/22
3:51 UTC
Read the original article
Hit count: 807
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
© Stack Overflow or respective owner