mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 20:25:50 +00:00
Create task that opens test results
This commit is contained in:
parent
6148ddd967
commit
c7dd21af0f
2 changed files with 28 additions and 1 deletions
27
build.gradle
27
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
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
rootProject.name = 'spring-petclinic'
|
||||
rootProject.name = 'spring-application'
|
||||
|
|
Loading…
Reference in a new issue