You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
cmnbroad
changed the title
CommandLineArgumentParser tests should only test one feature per test case
CommandLineParser tests should only test one feature per test case
Jan 14, 2019
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:This test passes because the call to
parseArguments
does returnfalse
, but the false value results not from the attempt to setTRUTHINESS
to null, but from the fact that an earlier call in the method toparseArguments
sets the value ofFROBNICATION_THRESHOLD
to null (previous value 20). BecauseFROBNICATION_THRESHOLD
has an initial value, the firstparseArguments
call treats it as optional. But once the state ofFROBNICATION_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 theTRUTHINESS
part of the test is never even triggered.All of the tests should be separated to ensure the starting state is consistent.
The text was updated successfully, but these errors were encountered: