diff --git a/README.md b/README.md index 2e383ed40..e4e09a0b6 100644 --- a/README.md +++ b/README.md @@ -81,16 +81,16 @@ For minimum requirements information and detailed instructions on how to use the The following actions are available when you select a project in the Liberty Tool Window. -| Action | Description | -|--------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Start | Start dev mode. | +| Action | Description | +|--------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Start | Start dev mode. | | Start… | Open the **Run Configurations** dialog to customize and start dev mode. Supported parameters can be found in the documentation for the [dev goal of the Liberty Maven Plugin](https://github.com/OpenLiberty/ci.maven/blob/master/docs/dev.md#additional-parameters) and the [libertyDev task of the Liberty Gradle Plugin](https://github.com/OpenLiberty/ci.gradle/blob/master/docs/libertyDev.md#command-line-parameters). | | Start in a container | Start dev mode with Liberty running in a container. The `liberty-maven-plugin` must be version `3.3-M1` or higher. The `liberty-gradle-plugin` must be version `3.1-M1` or higher. -| Stop | Stop dev mode. Liberty must be running in dev mode to use this command. | -| Run tests | Run the unit tests and integration tests that are configured for your project. Liberty must be running in dev mode to use this command. | -| View integration test report (Maven) | View the integration test report file if it exists at `/target/site/failsafe-report.html`. | -| View unit test report (Maven) | View the unit test report file if it exists at `/target/site/surefire-report.html`. | -| View test report (Gradle) | Open the test report file, if it exists at the `build/reports/tests/test/index.html` default location. This action command is available only to Gradle projects. Gradle projects have only a single action command for test result reporting. | +| Stop | Stop dev mode. Liberty must be running in dev mode to use this command. | +| Run tests | Run the unit tests and integration tests that are configured for your project. Liberty must be running in dev mode to use this command. | +| View integration test report (Maven) | View the integration test report file if it exists at `target/reports/failsafe.html` or `target/site/failsafe-report.html`. | +| View unit test report (Maven) | View the unit test report file if it exists at `target/reports/surefire.html` or `target/site/surefire-report.html`. | +| View test report (Gradle) | Open the test report file, if it exists at the `build/reports/tests/test/index.html` default location. This action command is available only to Gradle projects. Gradle projects have only a single action command for test result reporting. | ## Technical support If you experience a problem with this plugin you might be asked to collect language server messages to assist in problem determination. Follow these steps: diff --git a/docs/user-guide.md b/docs/user-guide.md index b843c701e..4e08c6771 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -123,11 +123,11 @@ After you finish running your application tests, you can access the produced tes To view the integration test report for Maven-built applications, select the **View integration test report** action for your application in the Liberty tool window. -This action looks for the integration test report at the `/target/site/failsafe-report.html` default location. +This action looks for the integration test report at two default locations: `target/reports/failsafe.html` and `target/site/failsafe-report.html`. To view the unit test report for Maven-built applications, select the **View unit test report** action for your application in the Liberty tool window. -This action looks for the unit test report at the `/target/site/surefire-report.html` default location. +This action looks for the unit test report at two default locations: `target/reports/surefire.html` and `target/site/surefire-report.html`. ### Gradle-built applications diff --git a/src/main/java/io/openliberty/tools/intellij/actions/ViewIntegrationTestReport.java b/src/main/java/io/openliberty/tools/intellij/actions/ViewIntegrationTestReport.java index 2a091530f..a1f408bed 100644 --- a/src/main/java/io/openliberty/tools/intellij/actions/ViewIntegrationTestReport.java +++ b/src/main/java/io/openliberty/tools/intellij/actions/ViewIntegrationTestReport.java @@ -20,6 +20,7 @@ import io.openliberty.tools.intellij.LibertyPluginIcons; import io.openliberty.tools.intellij.util.Constants; import io.openliberty.tools.intellij.util.LocalizedResourceUtil; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.nio.file.Paths; @@ -48,9 +49,16 @@ protected void executeLibertyAction(LibertyModule libertyModule) { // get path to project folder final VirtualFile parentFile = buildFile.getParent(); - File failsafeReportFile = Paths.get(parentFile.getPath(), "target", "site", "failsafe-report.html").normalize().toAbsolutePath().toFile(); - VirtualFile failsafeReportVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(failsafeReportFile); + // Dev mode runs the tests and it may have selected a report generator that uses one location and filename or another depending on the version number + // Maven plugin maven-surefire-report-plugin v3.5 and above use this location and filename + File failsafeReportFile = getReportFile(parentFile, "reports", "failsafe.html"); + VirtualFile failsafeReportVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(failsafeReportFile); + if (failsafeReportVirtualFile == null || !failsafeReportVirtualFile.exists()) { + // Maven plugin maven-surefire-report-plugin v3.4 and below use this location and filename + failsafeReportFile = getReportFile(parentFile, "site", "failsafe-report.html"); + failsafeReportVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(failsafeReportFile); + } if (failsafeReportVirtualFile == null || !failsafeReportVirtualFile.exists()) { Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, @@ -58,7 +66,6 @@ protected void executeLibertyAction(LibertyModule libertyModule) { LocalizedResourceUtil.getMessage("test.report.does.not.exist", failsafeReportFile.getAbsolutePath()), NotificationType.ERROR); notif.setIcon(LibertyPluginIcons.libertyIcon); - Notifications.Bus.notify(notif, project); LOGGER.debug("Integration test report does not exist at : " + failsafeReportFile.getAbsolutePath()); return; @@ -68,4 +75,9 @@ protected void executeLibertyAction(LibertyModule libertyModule) { BrowserUtil.browse(failsafeReportVirtualFile.getUrl()); } + @NotNull + private File getReportFile(VirtualFile parentFile, String dir, String filename) { + return Paths.get(parentFile.getPath(), "target", dir, filename).normalize().toAbsolutePath().toFile(); + } + } \ No newline at end of file diff --git a/src/main/java/io/openliberty/tools/intellij/actions/ViewUnitTestReport.java b/src/main/java/io/openliberty/tools/intellij/actions/ViewUnitTestReport.java index 604a925fa..2349ff936 100644 --- a/src/main/java/io/openliberty/tools/intellij/actions/ViewUnitTestReport.java +++ b/src/main/java/io/openliberty/tools/intellij/actions/ViewUnitTestReport.java @@ -20,6 +20,7 @@ import io.openliberty.tools.intellij.LibertyPluginIcons; import io.openliberty.tools.intellij.util.Constants; import io.openliberty.tools.intellij.util.LocalizedResourceUtil; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.nio.file.Paths; @@ -48,8 +49,16 @@ protected void executeLibertyAction(LibertyModule libertyModule) { // get path to project folder final VirtualFile parentFile = buildFile.getParent(); - File surefireReportFile = Paths.get(parentFile.getPath(), "target", "site", "surefire-report.html").normalize().toAbsolutePath().toFile(); + + // Dev mode runs the tests and it may have selected a report generator that uses one location or another depending on the version number + // Maven plugin maven-surefire-report-plugin v3.5 and above use this location + File surefireReportFile = getReportFile(parentFile, "reports", "surefire.html"); VirtualFile surefireReportVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(surefireReportFile); + if (surefireReportVirtualFile == null || !surefireReportVirtualFile.exists()) { + // Maven plugin maven-surefire-report-plugin v3.4 and below use this location + surefireReportFile = getReportFile(parentFile,"site", "surefire-report.html"); + surefireReportVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(surefireReportFile); + } if (surefireReportVirtualFile == null || !surefireReportVirtualFile.exists()) { Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, @@ -67,4 +76,8 @@ protected void executeLibertyAction(LibertyModule libertyModule) { BrowserUtil.browse(surefireReportVirtualFile.getUrl()); } + @NotNull + private File getReportFile(VirtualFile parentFile, String dir, String filename) { + return Paths.get(parentFile.getPath(), "target", dir, filename).normalize().toAbsolutePath().toFile(); + } } \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java index db74abf8c..a22df91ba 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java @@ -199,6 +199,7 @@ public void deleteTestReports() { */ @Override public void validateTestReportsExist() { - TestUtils.validateTestReportExists(TEST_REPORT_PATH); + //TODO: rewrite validateTestReportExists() to accept one argument or to accept a null as the second argument + TestUtils.validateTestReportExists(TEST_REPORT_PATH, TEST_REPORT_PATH); } } \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java index 32bc25c9a..7596d4205 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java @@ -253,6 +253,6 @@ public void deleteTestReports() { */ @Override public void validateTestReportsExist() { - TestUtils.validateTestReportExists(TEST_REPORT_PATH); + TestUtils.validateTestReportExists(TEST_REPORT_PATH, TEST_REPORT_PATH); } } \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java index 7ad687066..32a3a92d9 100755 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java @@ -63,14 +63,16 @@ public class MavenSingleModMPProjectTest extends SingleModMPProjectTestCommon { private final String BUILD_FILE_OPEN_CMD = "Liberty: View pom.xml"; /** - * The path to the integration test reports. + * The paths to the integration test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used. */ - private final Path pathToITReport = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "failsafe-report.html"); + private final Path pathToITReport34 = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "failsafe-report.html"); + private final Path pathToITReport35 = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "reports", "failsafe.html"); /** - * The path to the unit test reports. + * The paths to the unit test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used. */ - private final Path pathToUTReport = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "surefire-report.html"); + private final Path pathToUTReport34 = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "site", "surefire-report.html"); + private final Path pathToUTReport35 = Paths.get(PROJECTS_PATH, SM_MP_PROJECT_NAME, "target", "reports", "surefire.html"); /** * Dev mode configuration start parameters. @@ -198,11 +200,15 @@ public String getStartParamsDebugPort() { */ @Override public void deleteTestReports() { - boolean itReportDeleted = TestUtils.deleteFile(pathToITReport); - Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); - - boolean utReportDeleted = TestUtils.deleteFile(pathToUTReport); - Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport + " was not be deleted."); + boolean itReportDeleted = TestUtils.deleteFile(pathToITReport34); + Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport34 + " was not be deleted."); + itReportDeleted = TestUtils.deleteFile(pathToITReport35); + Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport35 + " was not be deleted."); + + boolean utReportDeleted = TestUtils.deleteFile(pathToUTReport34); + Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport34 + " was not be deleted."); + utReportDeleted = TestUtils.deleteFile(pathToUTReport35); + Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport35 + " was not be deleted."); } /** @@ -210,7 +216,7 @@ public void deleteTestReports() { */ @Override public void validateTestReportsExist() { - TestUtils.validateTestReportExists(pathToITReport); - TestUtils.validateTestReportExists(pathToUTReport); + TestUtils.validateTestReportExists(pathToITReport34, pathToITReport35); + TestUtils.validateTestReportExists(pathToUTReport34, pathToUTReport35); } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java index 3783ab661..186e7a4e9 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java @@ -68,16 +68,17 @@ public class MavenSingleModMPSIDProjectTest extends SingleModMPProjectTestCommon * Action command to open the build file. */ private final String BUILD_FILE_OPEN_CMD = "Liberty: View pom.xml"; - /** - * The path to the integration test reports. + * The paths to the integration test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used. */ - private final Path pathToITReport = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "target", "site", "failsafe-report.html"); + private final Path pathToITReport34 = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "target", "site", "failsafe-report.html"); + private final Path pathToITReport35 = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "target", "reports", "failsafe.html"); /** - * The path to the unit test reports. + * The paths to the unit test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used. */ - private final Path pathToUTReport = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "target", "site", "surefire-report.html"); + private final Path pathToUTReport34 = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "target", "site", "surefire-report.html"); + private final Path pathToUTReport35 = Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "target", "reports", "surefire.html"); /** * Dev mode configuration start parameters. @@ -225,11 +226,15 @@ public String getStartParamsDebugPort() { */ @Override public void deleteTestReports() { - boolean itReportDeleted = TestUtils.deleteFile(pathToITReport); - Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); - - boolean utReportDeleted = TestUtils.deleteFile(pathToUTReport); - Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport + " was not be deleted."); + boolean itReportDeleted = TestUtils.deleteFile(pathToITReport34); + Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport34 + " was not be deleted."); + itReportDeleted = TestUtils.deleteFile(pathToITReport35); + Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport35 + " was not be deleted."); + + boolean utReportDeleted = TestUtils.deleteFile(pathToUTReport34); + Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport34 + " was not be deleted."); + utReportDeleted = TestUtils.deleteFile(pathToUTReport35); + Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToUTReport35 + " was not be deleted."); } /** @@ -237,7 +242,7 @@ public void deleteTestReports() { */ @Override public void validateTestReportsExist() { - TestUtils.validateTestReportExists(pathToITReport); - TestUtils.validateTestReportExists(pathToUTReport); + TestUtils.validateTestReportExists(pathToITReport34, pathToITReport35); + TestUtils.validateTestReportExists(pathToUTReport34, pathToUTReport35); } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index a3bdb18e4..9fbbeccaf 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -370,11 +370,12 @@ public static void printLibertyMessagesLogFile(String msgHeader, String wlpMsgLo } /** - * Validates that the test report represented by the input path exists. + * Validates that one of the test reports represented by the input paths exists. * - * @param pathToTestReport The path to the report. + * @param pathToTestReport34 The path to the report for maven-surefire-report-plugin 3.4 or earlier + * @param pathToTestReport35 The path to the report for maven-surefire-report-plugin 3.5 or later */ - public static void validateTestReportExists(Path pathToTestReport) { + public static void validateTestReportExists(Path pathToTestReport34, Path pathToTestReport35) { int retryCountLimit = 100; int retryIntervalSecs = 1; int retryCount = 0; @@ -382,7 +383,7 @@ public static void validateTestReportExists(Path pathToTestReport) { while (retryCount < retryCountLimit) { retryCount++; - boolean fileExists = fileExists(pathToTestReport.toAbsolutePath()); + boolean fileExists = fileExists(pathToTestReport34.toAbsolutePath()) || fileExists(pathToTestReport35.toAbsolutePath()); if (!fileExists) { try { Thread.sleep(retryIntervalSecs * 1000); @@ -393,7 +394,7 @@ public static void validateTestReportExists(Path pathToTestReport) { return; } } - throw new IllegalStateException("Timed out waiting for test report: " + pathToTestReport + " file to be created."); + throw new IllegalStateException("Timed out waiting for test report: " + pathToTestReport34 + " or " + pathToTestReport35 + " file to be created."); } /**