Closed hohwille closed 3 years ago
PoC: I have created two such classes (2nd identical with 2 instead of 1):
public class BaseTestState1Test extends BaseTest {
@Override
protected void doSetUp() {
System.out.println("BaseTestState1Test - isInitialSetup() = " + isInitialSetup());
super.doSetUp();
}
@Test
public void test1() {
System.out.println("BaseTestState1Test - test1");
}
@Test
public void test2() {
System.out.println("BaseTestState1Test - test2");
}
}
Running JUnits gives me:
BaseTestState1Test - isInitialSetup() = false
BaseTestState1Test - test1
BaseTestState1Test - isInitialSetup() = true
BaseTestState1Test - test2
BaseTestState2Test - isInitialSetup() = true
BaseTestState2Test - test1
BaseTestState2Test - isInitialSetup() = true
BaseTestState2Test - test2
This obviously confirms the bug:
isInitialSetup()
boolean logic is inversedisInitialSetup()
fails to track its state across different JUnit classes since it uses a static flag that is shared by ALL inherited JUnits.
As already stated this can never have worked or be properly tested. What a shame...Now, it is trivial to fix this and with that fix I get:
BaseTestState1Test - isInitialSetup() = true
BaseTestState1Test - test1
BaseTestState1Test - isInitialSetup() = false
BaseTestState1Test - test2
BaseTestState2Test - isInitialSetup() = true
BaseTestState2Test - test1
BaseTestState2Test - isInitialSetup() = false
BaseTestState2Test - test2
With
BaseTest
we are providing a base-class for JUnit tests. It provides a feature that allows to determine if the test-class runs for the first time or you are in a sub-sequent run of an additional test method within the same JUnit test class.Unfortunately this feature seem to have been broken from the start and never worked. Only now with PR #365 we noticed that there is a fundamental bug that is needed to be fixed asap. Sorry for that and thanks for the feedback via PR #365 so we notice and can fix.