How is JUnit 4 suitable for creating test cases for using common functions: for example, a setting that is common to several unit test classes? What I did was create a test case and put the general functionality in the method @Before, then any test case that needs this will expand the base class. However, apparently, this requires execution: super.setUp()in each subclass.
Is there a better way?
EDIT
In fact, my proposed solution does not work. Sometimes JUnit will call the TWICE base class. Once this happens, to run the test in the base class first, and again when it reaches the child class (at least I think this is what happens). Thus, the best way to “inherit” the overall functionality of a test case would be great.
source
share