There are a lot of tests that are ganged up to test multiple features per case, but this can result in confusing and misleading results due to serial mutations of the test data. For example, the testNullOptionals method has code that purports to test that a required arg can't be set to NULL:
//verify that required arg can't be set to null
args[2] = "TRUTHINESS=null";
final LegacyCommandLineArgumentParser clp2 = new LegacyCommandLineArgumentParser(fownl);
Assert.assertFalse(clp2.parseArguments(System.err, args));
This test passes because the call to parseArguments does return false, but the false value results not from the attempt to set TRUTHINESS to null, but from the fact that an earlier call in the method to parseArguments sets the value of FROBNICATION_THRESHOLD to null (previous value 20). Because FROBNICATION_THRESHOLD has an initial value, the first parseArguments call treats it as optional. But once the state of FROBNICATION_THRESHOLD is set to null, the parser subsequently views it as required, and the next call returns false because of the attempt to set it to null. So the TRUTHINESS part of the test is never even triggered.
All of the tests should be separated to ensure the starting state is consistent.
There are a lot of tests that are ganged up to test multiple features per case, but this can result in confusing and misleading results due to serial mutations of the test data. For example, the
testNullOptionalsmethod has code that purports to test that a required arg can't be set to NULL:This test passes because the call to
parseArgumentsdoes returnfalse, but the false value results not from the attempt to setTRUTHINESSto null, but from the fact that an earlier call in the method toparseArgumentssets the value ofFROBNICATION_THRESHOLDto null (previous value 20). BecauseFROBNICATION_THRESHOLDhas an initial value, the firstparseArgumentscall treats it as optional. But once the state ofFROBNICATION_THRESHOLDis set to null, the parser subsequently views it as required, and the next call returns false because of the attempt to set it to null. So theTRUTHINESSpart of the test is never even triggered.All of the tests should be separated to ensure the starting state is consistent.