Generate and convert JUnit reports for xunit-viewer

This commit is contained in:
Erik C. Thauvin 2025-05-19 11:43:40 -07:00
parent 95df2d5838
commit 9f9fdac82e
Signed by: erik
GPG key ID: 776702A6A2DA330E

View file

@ -23,6 +23,9 @@ import rife.bld.publish.PublishDeveloper;
import rife.bld.publish.PublishLicense;
import rife.bld.publish.PublishScm;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static rife.bld.dependencies.Repository.*;
@ -34,13 +37,13 @@ public class JacocoReportOperationBuild extends Project {
public JacocoReportOperationBuild() {
pkg = "rife.bld.extension";
name = "JacocoReportOperation";
version = version(0, 9, 10);
version = version(0, 9, 11, "SNAPSHOT");
javaRelease = 17;
downloadSources = true;
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);
var jacocoVersion = new VersionNumber(0, 8, 13);
@ -107,6 +110,32 @@ public class JacocoReportOperationBuild extends Project {
.command("scripts/cliargs.sh")
.execute();
}
super.test();
var testResultsDir = "build/test-results/test/";
var op = testOperation().fromProject(this);
op.testToolOptions().reportsDir(new File(testResultsDir));
Exception ex = null;
try {
op.execute();
} catch (Exception e) {
ex = e;
}
var xunitViewer = new File("/usr/bin/xunit-viewer");
if (xunitViewer.exists() && xunitViewer.canExecute()) {
var reportsDir = "build/reports/tests/test/";
Files.createDirectories(Path.of(reportsDir));
new ExecOperation()
.fromProject(this)
.command(xunitViewer.getPath(), "-r", testResultsDir, "-o", reportsDir + "index.html")
.execute();
}
if (ex != null) {
throw ex;
}
}
}