aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorAmaury Levé <amaury.leve@sonarsource.com>2018-04-26 10:21:53 +0200
committerGitHub <noreply@github.com>2018-04-26 10:21:53 +0200
commit6b728171c3222c8e6697bb1c7e0616a6c9e5fc76 (patch)
tree7174f0be78a9c06962018cc24a984f2cae49f824 /src/test/java/org
parentc538e5bfb98002c9e1124bb1ddc74fa3e274cf72 (diff)
downloadsonar-scanner-cli-6b728171c3222c8e6697bb1c7e0616a6c9e5fc76.tar.gz
sonar-scanner-cli-6b728171c3222c8e6697bb1c7e0616a6c9e5fc76.zip
SQSCANNER-49: Don't suggest debug if CLI is embeded (#48)
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/sonarsource/scanner/cli/MainTest.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/MainTest.java b/src/test/java/org/sonarsource/scanner/cli/MainTest.java
index 4c45f95..e746fe8 100644
--- a/src/test/java/org/sonarsource/scanner/cli/MainTest.java
+++ b/src/test/java/org/sonarsource/scanner/cli/MainTest.java
@@ -114,17 +114,36 @@ public class MainTest {
@Test
public void show_error_MessageException() {
Exception e = createException(true);
- testException(e, false);
+ testException(e, false, false);
verify(logs).error("Error during SonarQube Scanner execution");
verify(logs).error("Caused by: NPE");
verify(logs).error("Re-run SonarQube Scanner using the -X switch to enable full debug logging.");
}
+
+ @Test
+ public void show_error_MessageException_embedded() {
+ Exception e = createException(true);
+ testException(e, false, true);
+
+ verify(logs).error("Error during SonarQube Scanner execution");
+ verify(logs).error("Caused by: NPE");
+ }
@Test
public void show_error_MessageException_debug() {
Exception e = createException(true);
- testException(e, true);
+ testException(e, true, false);
+
+ verify(logs).error("Error during SonarQube Scanner execution");
+ verify(logs).error("my message");
+ verify(logs).error("Caused by: NPE");
+ }
+
+ @Test
+ public void show_error_MessageException_debug_embedded() {
+ Exception e = createException(true);
+ testException(e, true, true);
verify(logs).error("Error during SonarQube Scanner execution");
verify(logs).error("my message");
@@ -134,14 +153,15 @@ public class MainTest {
@Test
public void show_error_debug() {
Exception e = createException(false);
- testException(e, true);
+ testException(e, true, false);
verify(logs).error("Error during SonarQube Scanner execution", e);
verify(logs, never()).error("Re-run SonarQube Scanner using the -X switch to enable full debug logging.");
}
- private void testException(Exception e, boolean debugEnabled) {
+ private void testException(Exception e, boolean debugEnabled, boolean isEmbedded) {
when(cli.isDebugEnabled()).thenReturn(debugEnabled);
+ when(cli.isEmbedded()).thenReturn(isEmbedded);
EmbeddedScanner runner = mock(EmbeddedScanner.class);
doThrow(e).when(runner).execute(any(Map.class));