From c7dd21af0f224d144b13a87c0ed183cf529c5234 Mon Sep 17 00:00:00 2001 From: Mihailo Marcetic Date: Fri, 31 Jan 2025 11:21:38 +0100 Subject: [PATCH] Create task that opens test results --- build.gradle | 27 +++++++++++++++++++++++++++ settings.gradle | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 17c3763e2..69473b570 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,11 @@ plugins { id 'org.cyclonedx.bom' version '1.10.0' id 'io.spring.javaformat' version '0.0.43' id "io.spring.nohttp" version "0.0.11" + id("pl.allegro.tech.build.axion-release") version "1.18.7" } +version = scmVersion.version + apply plugin: 'java' apply plugin: 'checkstyle' apply plugin: 'io.spring.javaformat' @@ -80,6 +83,30 @@ tasks.named("formatMain").configure { dependsOn("checkstyleNohttp") } tasks.named("formatTest").configure { dependsOn("checkstyleTest") } tasks.named("formatTest").configure { dependsOn("checkstyleNohttp") } + +task openTestResults(dependsOn: ['build', 'test']) { + doLast { + def testResultsFile = file('build/reports/tests/test/index.html') + + if (testResultsFile.exists()) { + println "Opening test results in the browser..." + // Open the test results file in the default browser (cross-platform) + if (System.getProperty('os.name').toLowerCase().contains('win')) { + // On Windows, use "start" + "cmd /c start ${testResultsFile}".execute() + } else if (System.getProperty('os.name').toLowerCase().contains('mac')) { + // On macOS, use "open" + "open ${testResultsFile}".execute() + } else { + // On Linux, use "xdg-open" + "xdg-open ${testResultsFile}".execute() + } + } else { + throw new GradleException("Test results file not found: ${testResultsFile}") + } + } +} + checkstyleAot.enabled = false checkstyleAotTest.enabled = false diff --git a/settings.gradle b/settings.gradle index e60ee14fa..c9cf4f1fc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = 'spring-petclinic' +rootProject.name = 'spring-application'