diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-09-14 17:51:40 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-09-14 18:08:36 +0200 |
commit | 89fac82713095f2ff85703fb6223a02e4b5b818d (patch) | |
tree | 3453fb7bdb88efd0f5bc7b713084475bcdc89e09 /src/test/java/org/sonarsource/scanner | |
parent | 516ba9b922f4dab9f72077ee5ebf6eebda6c0d3a (diff) | |
download | sonar-scanner-cli-89fac82713095f2ff85703fb6223a02e4b5b818d.tar.gz sonar-scanner-cli-89fac82713095f2ff85703fb6223a02e4b5b818d.zip |
SQSCANNER-29 Exit code should not be 0 when script fails due to ERROR: Unrecognized option
Diffstat (limited to 'src/test/java/org/sonarsource/scanner')
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/CliTest.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/CliTest.java b/src/test/java/org/sonarsource/scanner/cli/CliTest.java index 6bac2d0..840f35b 100644 --- a/src/test/java/org/sonarsource/scanner/cli/CliTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/CliTest.java @@ -23,6 +23,7 @@ import org.junit.Test; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; public class CliTest { Exit exit = mock(Exit.class); @@ -77,4 +78,23 @@ public class CliTest { assertThat(cli.isDisplayStackTrace()).isFalse(); assertThat(cli.properties().get("sonar.verbose")).isNull(); } + + @Test + public void should_show_usage() { + logs = mock(Logs.class); + cli = new Cli(exit, logs); + cli.parse(new String[] {"-h"}); + verify(logs).info("usage: sonar-scanner [options]"); + verify(exit).exit(Exit.SUCCESS); + } + + @Test + public void should_show_usage_on_bad_syntax() { + logs = mock(Logs.class); + cli = new Cli(exit, logs); + cli.parse(new String[] {"-w"}); + verify(logs).error("Unrecognized option: -w"); + verify(logs).info("usage: sonar-scanner [options]"); + verify(exit).exit(Exit.ERROR); + } } |