From 69e3aaf79ff20112e7d791816901131f009118b7 Mon Sep 17 00:00:00 2001 From: Kristof Neirynck Date: Thu, 20 Feb 2014 15:33:13 +0100 Subject: [PATCH] fix #38 Save a reportfile even when there are no problems including test --- src/main/java/com/cj/jshintmojo/Mojo.java | 2 +- src/test/java/com/cj/jshintmojo/MojoTest.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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 {