Generate and convert JUnit report for xunit-viewer

This commit is contained in:
Erik C. Thauvin 2025-05-19 12:40:01 -07:00
parent 9d8ab4a7bc
commit 86c8cd9956
Signed by: erik
GPG key ID: 776702A6A2DA330E
3 changed files with 32 additions and 4 deletions

View file

@ -22,6 +22,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 java.util.Locale;
@ -107,6 +110,32 @@ public class CheckstyleOperationBuild 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;
}
}
}