### Question:
EcLog { private static ToolOptions getToolOptions(String... argv) { return getToolOptions(argv, new OptionParser(), System::exit); } private  EcLog(); static void main(String[] argv);  }### Answer:
@Test public void testWorking() throws ParseException { when(parser.parse(any(String.class))).thenReturn(options); ToolOptions actualOptions = EcLog.getToolOptions(new String[]{ "some/path" }, parser, exiter); assertThat(actualOptions).isEqualTo(options); }
@Test public void testHelp() throws ParseException { when(parser.parse(any(String.class))).thenReturn(options); when(options.help()).thenReturn(true); EcLog.getToolOptions(new String[]{ "-h" }, parser, exiter); verify(parser).printUsage(); verify(exiter).accept(eq(0)); }
@Test public void testInvalidArgument() throws ParseException { when(parser.parse(any(String.class))).thenThrow(new ParseException("Invalid argument")); EcLog.getToolOptions(new String[]{ "--wrong" }, parser, exiter); verify(parser).printUsage(); verify(exiter).accept(eq(1)); }