]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
Improve test coverage
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 23 Aug 2016 12:44:56 +0000 (14:44 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 23 Aug 2016 12:44:56 +0000 (14:44 +0200)
src/main/java/org/sonarsource/scanner/cli/Main.java
src/test/java/org/sonarsource/scanner/cli/ConfTest.java

index 19b953c8c149f7dbcb7288a11ce39a399c7ada31..9833c85b73471726f645ae3922f7dc32d78eec2c 100644 (file)
@@ -36,7 +36,7 @@ import org.sonarsource.scanner.api.EmbeddedScanner;
  * @since 1.0
  */
 public class Main {
-
+  private static final String SEPARATOR = "------------------------------------------------------------------------";
   private final Exit exit;
   private final Cli cli;
   private final Conf conf;
@@ -112,11 +112,11 @@ public class Main {
   }
 
   private void displayExecutionResult(Stats stats, String resultMsg) {
-    logger.info("------------------------------------------------------------------------");
+    logger.info(SEPARATOR);
     logger.info("EXECUTION " + resultMsg);
-    logger.info("------------------------------------------------------------------------");
+    logger.info(SEPARATOR);
     stats.stop();
-    logger.info("------------------------------------------------------------------------");
+    logger.info(SEPARATOR);
   }
 
   private void showError(String message, Throwable e, boolean showStackTrace) {
index 66e61e8a29050262c85605451d90e899b2025309..4b11a073d77a4154ac42e454392bbc9913353b59 100644 (file)
@@ -231,6 +231,26 @@ public class ConfTest {
     assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(projectHome.toString());
   }
 
+  @Test
+  public void failModuleBaseDirDoesNotExist() throws IOException {
+    args.setProperty("sonar.modules", "module1");
+    args.setProperty("module1.sonar.projectBaseDir", "invalid");
+
+    exception.expect(IllegalStateException.class);
+    exception.expectMessage("The base directory of the module 'module1' does not exist");
+    conf.properties();
+  }
+
+  @Test
+  public void failModulePropertyFileDoesNotExist() throws IOException {
+    args.setProperty("sonar.modules", "module1");
+    args.setProperty("module1.sonar.projectConfigFile", "invalid");
+
+    exception.expect(IllegalStateException.class);
+    exception.expectMessage("The properties file of the module 'module1' does not exist");
+    conf.properties();
+  }
+
   @Test
   public void shouldSupportSettingBaseDirFromCli() throws Exception {
     Path projectHome = Paths.get(getClass().getResource("ConfTest/shouldLoadModuleConfiguration/project").toURI());