diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2017-01-13 11:36:34 +0100 |
---|---|---|
committer | Julien HENRY <henryju@yahoo.fr> | 2017-01-13 11:58:22 +0100 |
commit | 25b8af28ff4636a8222cc65af59200ac7140ff67 (patch) | |
tree | 3325bd762659df6d3472a8e37e88ddfce1800340 /src/test | |
parent | ae19303ed23f5120e228a4f7cdfb4ebe383abbd5 (diff) | |
download | sonar-scanner-cli-25b8af28ff4636a8222cc65af59200ac7140ff67.tar.gz sonar-scanner-cli-25b8af28ff4636a8222cc65af59200ac7140ff67.zip |
SQSCANNER-36 Don't loose error message in case of low level error (like OOM)
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/MainTest.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/MainTest.java b/src/test/java/org/sonarsource/scanner/cli/MainTest.java index b410cbd..9fd5f22 100644 --- a/src/test/java/org/sonarsource/scanner/cli/MainTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/MainTest.java @@ -79,7 +79,7 @@ public class MainTest { } @Test - public void should_stop_on_error() { + public void should_call_stop_on_error_during_analysis() { EmbeddedScanner runner = mock(EmbeddedScanner.class); Exception e = new NullPointerException("NPE"); e = new IllegalStateException("Error", e); @@ -95,6 +95,24 @@ public class MainTest { } @Test + public void should_not_call_stop_on_error_during_start() { + EmbeddedScanner runner = mock(EmbeddedScanner.class); + Exception e = new NullPointerException("NPE"); + e = new IllegalStateException("Error", e); + doThrow(e).when(runner).start(); + when(runnerFactory.create(any(Properties.class))).thenReturn(runner); + + Main main = new Main(exit, cli, conf, runnerFactory, logs); + main.execute(); + + verify(runner).start(); + verify(runner, never()).runAnalysis(any()); + verify(runner, never()).stop(); + verify(exit).exit(Exit.ERROR); + verify(logs).error("Error during SonarQube Scanner execution", e); + } + + @Test public void should_exit_on_error() { EmbeddedScanner runner = mock(EmbeddedScanner.class); Exception e = new NullPointerException("NPE"); |