diff --git a/.aliases b/.aliases index 55a53503..8f8fafc2 100644 --- a/.aliases +++ b/.aliases @@ -96,5 +96,5 @@ if [ ! -f .environment ]; then fi source .environment -alias scenario-reports-upload='./gradlew convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office' -alias scenario-reports-online='open https://hsngdev.hs-example.de/scenarios/office' +alias scenario-reports-upload='./gradlew scenarioTests convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm -f doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp build/doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office' +alias scenario-reports-open='open https://hsngdev.hs-example.de/scenarios/office' diff --git a/build.gradle b/build.gradle index c07888f5..2a33cacf 100644 --- a/build.gradle +++ b/build.gradle @@ -233,7 +233,7 @@ dependencyCheck { failBuildOnCVSS = 5 } project.tasks.check.dependsOn(dependencyCheckAnalyze) -project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.md! +project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.txt! println "OWASP Dependency Security Report: file:///${project.rootDir}/build/reports/dependency-check-report.html" } @@ -268,7 +268,7 @@ jacocoTestReport { ]) })) } - doFirst { // Why not doLast? See README.md! + doFirst { // Why not doLast? See README.txt! println "HTML Jacoco Test Code Coverage Report: file://${reports.html.outputLocation.get()}/index.html" } } @@ -381,7 +381,7 @@ pitest { timestampedReports = false } project.tasks.check.dependsOn(project.tasks.pitest) -project.tasks.pitest.doFirst { // Why not doLast? See README.md! +project.tasks.pitest.doFirst { // Why not doLast? See README.txt! println "PiTest Mutation Report: file:///${project.rootDir}/build/reports/pitest/index.html" } @@ -431,7 +431,7 @@ tasks.register('convertMarkdownToHtml') { doLast { // Gather all Markdown files in the current directory - fileTree(dir: '.', include: 'doc/scenarios/*.md').each { file -> + fileTree(dir: '.', include: 'build/doc/scenarios/*.md').each { file -> // Corrected way to create the output file path def outputFile = new File(file.parent, file.name.replaceAll(/\.md$/, '.html')) @@ -444,3 +444,4 @@ tasks.register('convertMarkdownToHtml') { } } } +convertMarkdownToHtml.dependsOn scenarioTests diff --git a/doc/scenarios/README.txt b/doc/scenarios/README.txt new file mode 100644 index 00000000..1f5c2b4b --- /dev/null +++ b/doc/scenarios/README.txt @@ -0,0 +1 @@ +move generated ScenarioReports to build-dir diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java index 007e4512..2baa3a62 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java @@ -19,7 +19,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestReport { - private final static File markdownLogFile = new File("doc/scenarios/.last-debug-log.md"); + public static final File BUILD_DOC_SCENARIOS = new File("build/doc/scenarios"); + private final static File markdownLogFile = new File(BUILD_DOC_SCENARIOS, ".last-debug-log.md"); public static final SimpleDateFormat MM_DD_YYYY_HH_MM_SS = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss"); private final Map aliases; @@ -28,6 +29,11 @@ public class TestReport { private PrintWriter markdownReport; // records only the use-case under test, without its pre-requisites private int silent; // do not print anything to test-report if >0 + static { + assertThat(BUILD_DOC_SCENARIOS.isDirectory() || BUILD_DOC_SCENARIOS.mkdirs()) + .as("mkdir " + BUILD_DOC_SCENARIOS).isTrue(); + } + @SneakyThrows public TestReport(final Map aliases) { this.aliases = aliases; @@ -37,8 +43,7 @@ public class TestReport { public void createTestLogMarkdownFile(final TestInfo testInfo) throws IOException { final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow(); final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow(); - assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue(); - markdownReportFile = new File("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"); + markdownReportFile = new File(BUILD_DOC_SCENARIOS, testMethodOrder + "-" + testMethodName + ".md"); markdownReport = new PrintWriter(new FileWriter(markdownReportFile)); print("## Scenario #" + determineScenarioTitle(testInfo)); }