@Test public void shouldParseServeCommand() throws Exception { final int port = randomPort(); final String host = randomString(); final String profile = randomString(); final Path first = folder.newFolder().toPath(); final Path second = folder.newFolder().toPath(); final Optional<ExitCode> code = commandLine.parse( SERVE_COMMAND, "--port", String.valueOf(port), "--host", host, "--profile", profile, first.toString(), second.toString() ); assertThat(code) .isEmpty(); final ArgumentCaptor<ConfigOptions> captor = ArgumentCaptor.forClass(ConfigOptions.class); when(commands.serve(eq(Arrays.asList(first, second)), eq(host), eq(port), captor.capture())).thenReturn(NO_ERROR); final ExitCode run = commandLine.run(); assertThat(run) .isEqualTo(NO_ERROR); assertThat(captor.getAllValues()) .hasSize(1) .extracting(ConfigOptions::getProfile) .containsExactly(profile); }