diff --git a/src/main/java/com/cj/jshintmojo/Mojo.java b/src/main/java/com/cj/jshintmojo/Mojo.java index 2dd9024..ab9e5b7 100644 --- a/src/main/java/com/cj/jshintmojo/Mojo.java +++ b/src/main/java/com/cj/jshintmojo/Mojo.java @@ -300,8 +300,8 @@ private void handleResults(final Map currentResults, } } + saveReportFile(currentResults, reporter, reportFile); if(numProblematicFiles > 0) { - saveReportFile(currentResults, reporter, reportFile); String errorMessage = "\nJSHint found problems with " + numProblematicFiles + " file"; diff --git a/src/test/java/com/cj/jshintmojo/MojoTest.java b/src/test/java/com/cj/jshintmojo/MojoTest.java index b5b4b5c..0d8f7eb 100644 --- a/src/test/java/com/cj/jshintmojo/MojoTest.java +++ b/src/test/java/com/cj/jshintmojo/MojoTest.java @@ -53,6 +53,25 @@ public void walksTheDirectoryTreeToFindAndUseJshintFiles() throws Exception { } } } + + @Test + public void savesReportEvenWhenThereAreNoProblems() throws Exception { + // given + File directory = tempDir(); + File reportFile = new File(directory, "reportFile"); + + LogStub log = new LogStub(); + Mojo mojo = new Mojo("", "", + directory, + Collections.singletonList(""), + Collections.emptyList(),true, null, "jslint", reportFile.getAbsolutePath(), null); + mojo.setLog(log); + // when + mojo.execute(); + // then + assertTrue("Saves report", log.hasMessage("info", + "Generating \"JSHint\" report. reporter=jslint, reportFile="+reportFile.getAbsolutePath()+".")); + } @Test public void warnsUsersWhenConfiguredToWorkWithNonexistentDirectories() throws Exception {