I’m having a total brainfart on using commons-CLI and PosixParser. For some reason, the following test is failing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
    @Test
    public void testSpikeOnPosixParser() throws Exception {
 
        Options options = new Options();
        options.addOption("m", "multichar", true, "some description");
 
        CommandLineParser cmdLineParser = new PosixParser();
        CommandLine cmdLine = cmdLineParser.parse(options, new String[] {"-multichar", "somevalue"});
 
        assertNotNull(cmdLine);
        assertTrue(cmdLine.hasOption("multichar"));
        assertEquals("somevalue", cmdLine.getOptionValue("multichar"));
 
 
    }

The test fails at the assertTrue statement on line 12.

Why? Am I misunderstanding the JavaDocs? Or am I being a dunce and forgot how to use commons-cli?

Arg.