Generate and convert JUnit reports for xunit-viewer
This commit is contained in:
parent
3eeae9c19b
commit
3fe4c9cfc5
2 changed files with 56 additions and 32 deletions
|
@ -4,7 +4,7 @@ bld.downloadLocation=
|
||||||
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT
|
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT
|
||||||
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT
|
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT
|
||||||
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5
|
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5
|
||||||
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
|
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.11-SNAPSHOT
|
||||||
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
|
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
|
||||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
bld.sourceDirectories=
|
bld.sourceDirectories=
|
||||||
|
|
|
@ -58,6 +58,7 @@ import static rife.bld.dependencies.Scope.compile;
|
||||||
import static rife.bld.dependencies.Scope.test;
|
import static rife.bld.dependencies.Scope.test;
|
||||||
|
|
||||||
public class BitlyShortenBuild extends Project {
|
public class BitlyShortenBuild extends Project {
|
||||||
|
static final String TEST_RESULTS_DIR = "build/test-results/test/";
|
||||||
final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
|
final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
|
||||||
|
|
||||||
public BitlyShortenBuild() {
|
public BitlyShortenBuild() {
|
||||||
|
@ -184,10 +185,60 @@ public class BitlyShortenBuild extends Project {
|
||||||
|
|
||||||
@BuildCommand(summary = "Generates JaCoCo Reports")
|
@BuildCommand(summary = "Generates JaCoCo Reports")
|
||||||
public void jacoco() throws Exception {
|
public void jacoco() throws Exception {
|
||||||
new JacocoReportOperation()
|
var op = new JacocoReportOperation().fromProject(this);
|
||||||
.fromProject(this)
|
op.testToolOptions("--reports-dir=" + TEST_RESULTS_DIR);
|
||||||
.sourceFiles(srcMainKotlin)
|
|
||||||
.execute();
|
Exception ex = null;
|
||||||
|
try {
|
||||||
|
op.execute();
|
||||||
|
} catch (Exception e) {
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderWithXunitViewer();
|
||||||
|
|
||||||
|
if (ex != null) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
|
||||||
|
public void pomRoot() throws FileUtilsErrorException {
|
||||||
|
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
|
||||||
|
new File(workDirectory, "pom.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderWithXunitViewer() throws Exception {
|
||||||
|
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", TEST_RESULTS_DIR, "-o", reportsDir + "index.html")
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void test() throws Exception {
|
||||||
|
var op = testOperation().fromProject(this);
|
||||||
|
op.testToolOptions().reportsDir(new File(TEST_RESULTS_DIR));
|
||||||
|
|
||||||
|
Exception ex = null;
|
||||||
|
try {
|
||||||
|
op.execute();
|
||||||
|
} catch (Exception e) {
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderWithXunitViewer();
|
||||||
|
|
||||||
|
if (ex != null) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -213,31 +264,4 @@ public class BitlyShortenBuild extends Project {
|
||||||
super.publishLocal();
|
super.publishLocal();
|
||||||
pomRoot();
|
pomRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
|
|
||||||
public void pomRoot() throws FileUtilsErrorException {
|
|
||||||
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
|
|
||||||
new File(workDirectory, "pom.xml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void test() throws Exception {
|
|
||||||
var testResultsDir = "build/test-results/test/";
|
|
||||||
|
|
||||||
var op = testOperation().fromProject(this);
|
|
||||||
op.testToolOptions().reportsDir(new File(testResultsDir));
|
|
||||||
op.execute();
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue