Compare commits
No commits in common. "1fa49262a41cab75dc5c7f321619736a9ea55451" and "5a44d8b3d55324c539fd5b9efa6b1b6a0c370ecf" have entirely different histories.
1fa49262a4
...
5a44d8b3d5
7 changed files with 120 additions and 470 deletions
1
.github/workflows/bld.yml
vendored
1
.github/workflows/bld.yml
vendored
|
@ -7,6 +7,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [ 17, 21, 24 ]
|
java-version: [ 17, 21, 24 ]
|
||||||
|
kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ]
|
||||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -45,7 +45,7 @@
|
||||||
</option>
|
</option>
|
||||||
<option name="skipTestSources" value="false" />
|
<option name="skipTestSources" value="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build" />
|
<output url="file://$PROJECT_DIR$/build" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -25,8 +25,8 @@ public class ExamplesBuild extends Project {
|
||||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
||||||
|
|
||||||
scope(test)
|
scope(test)
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)));
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -2,6 +2,6 @@ bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.downloadLocation=
|
bld.downloadLocation=
|
||||||
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5
|
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5
|
||||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.3
|
bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.2
|
||||||
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
bld.version=2.2.1
|
bld.version=2.2.1
|
||||||
|
|
|
@ -23,9 +23,6 @@ import rife.bld.publish.PublishDeveloper;
|
||||||
import rife.bld.publish.PublishLicense;
|
import rife.bld.publish.PublishLicense;
|
||||||
import rife.bld.publish.PublishScm;
|
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.List;
|
||||||
|
|
||||||
import static rife.bld.dependencies.Repository.*;
|
import static rife.bld.dependencies.Repository.*;
|
||||||
|
@ -37,7 +34,7 @@ public class JacocoReportOperationBuild extends Project {
|
||||||
public JacocoReportOperationBuild() {
|
public JacocoReportOperationBuild() {
|
||||||
pkg = "rife.bld.extension";
|
pkg = "rife.bld.extension";
|
||||||
name = "JacocoReportOperation";
|
name = "JacocoReportOperation";
|
||||||
version = version(0, 9, 11, "SNAPSHOT");
|
version = version(0, 9, 10);
|
||||||
|
|
||||||
javaRelease = 17;
|
javaRelease = 17;
|
||||||
|
|
||||||
|
@ -51,8 +48,8 @@ public class JacocoReportOperationBuild extends Project {
|
||||||
.include(dependency("org.jacoco", "jacoco", jacocoVersion).exclude("*", "org.jacoco.doc"))
|
.include(dependency("org.jacoco", "jacoco", jacocoVersion).exclude("*", "org.jacoco.doc"))
|
||||||
.include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1)));
|
.include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1)));
|
||||||
scope(test)
|
scope(test)
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)))
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1)))
|
||||||
.include(dependency("org.assertj", "assertj-core", version(3, 27, 3)));
|
.include(dependency("org.assertj", "assertj-core", version(3, 27, 3)));
|
||||||
|
|
||||||
javadocOperation()
|
javadocOperation()
|
||||||
|
@ -110,32 +107,6 @@ public class JacocoReportOperationBuild extends Project {
|
||||||
.command("scripts/cliargs.sh")
|
.command("scripts/cliargs.sh")
|
||||||
.execute();
|
.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,10 +61,6 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
* The location of the source files.
|
* The location of the source files.
|
||||||
*/
|
*/
|
||||||
final private Collection<File> sourceFiles_ = new ArrayList<>();
|
final private Collection<File> sourceFiles_ = new ArrayList<>();
|
||||||
/**
|
|
||||||
* The test tool options.
|
|
||||||
*/
|
|
||||||
final private Collection<String> testToolOptions_ = new ArrayList<>();
|
|
||||||
/**
|
/**
|
||||||
* The location of the CSV report.
|
* The location of the CSV report.
|
||||||
*/
|
*/
|
||||||
|
@ -216,15 +212,6 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
return csv(csv.toFile());
|
return csv(csv.toFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the CSV report location.
|
|
||||||
*
|
|
||||||
* @return the CSV report location
|
|
||||||
*/
|
|
||||||
public File csv() {
|
|
||||||
return csv_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the file to write execution data to.
|
* Sets the file to write execution data to.
|
||||||
*
|
*
|
||||||
|
@ -256,15 +243,6 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
return destFile(destFile.toFile());
|
return destFile(destFile.toFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the file to write execution data to.
|
|
||||||
*
|
|
||||||
* @return the file to write execution data to
|
|
||||||
*/
|
|
||||||
public File destFile() {
|
|
||||||
return destFile_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the source file encoding. The platform encoding is used by default.
|
* Sets the source file encoding. The platform encoding is used by default.
|
||||||
*
|
*
|
||||||
|
@ -276,15 +254,6 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the source file encoding.
|
|
||||||
*
|
|
||||||
* @return the source file encoding
|
|
||||||
*/
|
|
||||||
public String encoding() {
|
|
||||||
return encoding_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the locations of the JaCoCo *.exec files to read.
|
* Sets the locations of the JaCoCo *.exec files to read.
|
||||||
*
|
*
|
||||||
|
@ -387,10 +356,6 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
"org.jacoco.agent-" + JaCoCo.VERSION.substring(0, JaCoCo.VERSION.lastIndexOf('.'))
|
"org.jacoco.agent-" + JaCoCo.VERSION.substring(0, JaCoCo.VERSION.lastIndexOf('.'))
|
||||||
+ "-runtime.jar").toFile(), "destfile=" + destFile_.getPath());
|
+ "-runtime.jar").toFile(), "destfile=" + destFile_.getPath());
|
||||||
|
|
||||||
if (!testToolOptions_.isEmpty()) {
|
|
||||||
testOperation.testToolOptions().addAll(testToolOptions_);
|
|
||||||
}
|
|
||||||
|
|
||||||
testOperation.execute();
|
testOperation.execute();
|
||||||
|
|
||||||
if (LOGGER.isLoggable(Level.INFO) && !silent()) {
|
if (LOGGER.isLoggable(Level.INFO) && !silent()) {
|
||||||
|
@ -446,7 +411,7 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
/**
|
/**
|
||||||
* Sets the location of the HTML report.
|
* Sets the location of the HTML report.
|
||||||
*
|
*
|
||||||
* @param html the HTML
|
* @param html the html
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public JacocoReportOperation html(File html) {
|
public JacocoReportOperation html(File html) {
|
||||||
|
@ -457,7 +422,7 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
/**
|
/**
|
||||||
* Sets the location of the HTML report.
|
* Sets the location of the HTML report.
|
||||||
*
|
*
|
||||||
* @param html the HTML
|
* @param html the html
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public JacocoReportOperation html(String html) {
|
public JacocoReportOperation html(String html) {
|
||||||
|
@ -467,31 +432,13 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
/**
|
/**
|
||||||
* Sets the location of the HTML report.
|
* Sets the location of the HTML report.
|
||||||
*
|
*
|
||||||
* @param html the HTML
|
* @param html the html
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public JacocoReportOperation html(Path html) {
|
public JacocoReportOperation html(Path html) {
|
||||||
return html(html.toFile());
|
return html(html.toFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the HTML report location.
|
|
||||||
*
|
|
||||||
* @return the HTML report location
|
|
||||||
*/
|
|
||||||
public File html() {
|
|
||||||
return html_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the status of the quiet flag.
|
|
||||||
*
|
|
||||||
* @return {@code true} if enabled, {@code false} otherwise
|
|
||||||
*/
|
|
||||||
public boolean isQuiet() {
|
|
||||||
return silent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ExecFileLoader loadExecFiles() throws IOException {
|
private ExecFileLoader loadExecFiles() throws IOException {
|
||||||
var loader = new ExecFileLoader();
|
var loader = new ExecFileLoader();
|
||||||
if (execFiles_.isEmpty() && LOGGER.isLoggable(Level.WARNING) && !silent()) {
|
if (execFiles_.isEmpty() && LOGGER.isLoggable(Level.WARNING) && !silent()) {
|
||||||
|
@ -519,15 +466,6 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name used for the report.
|
|
||||||
*
|
|
||||||
* @return the report name.
|
|
||||||
*/
|
|
||||||
public String name() {
|
|
||||||
return reportName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suppresses all output.
|
* Suppresses all output.
|
||||||
*
|
*
|
||||||
|
@ -656,47 +594,6 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the tab stop width for the source pages.
|
|
||||||
*
|
|
||||||
* @return the tab stop width
|
|
||||||
*/
|
|
||||||
public int tabWidth() {
|
|
||||||
return tabWidth_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the test tool options.
|
|
||||||
*
|
|
||||||
* @return the test tool options
|
|
||||||
*/
|
|
||||||
public Collection<String> testToolOptions() {
|
|
||||||
return testToolOptions_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the test tool options.
|
|
||||||
*
|
|
||||||
* @param options The options to set
|
|
||||||
* @return this operation instance
|
|
||||||
* @see #testToolOptions(Collection)
|
|
||||||
*/
|
|
||||||
public JacocoReportOperation testToolOptions(String... options) {
|
|
||||||
return testToolOptions(List.of(options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the test tool options.
|
|
||||||
*
|
|
||||||
* @param options The options to set
|
|
||||||
* @return this operation instance
|
|
||||||
* @see #testToolOptions(String...)
|
|
||||||
*/
|
|
||||||
public JacocoReportOperation testToolOptions(Collection<String> options) {
|
|
||||||
testToolOptions_.addAll(options);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeReports(IBundleCoverage bundle, ExecFileLoader loader)
|
private void writeReports(IBundleCoverage bundle, ExecFileLoader loader)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (LOGGER.isLoggable(Level.INFO) && !silent()) {
|
if (LOGGER.isLoggable(Level.INFO) && !silent()) {
|
||||||
|
@ -745,13 +642,4 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
||||||
public JacocoReportOperation xml(Path xml) {
|
public JacocoReportOperation xml(Path xml) {
|
||||||
return xml(xml.toFile());
|
return xml(xml.toFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the XML report location.
|
|
||||||
*
|
|
||||||
* @return the XML report location
|
|
||||||
*/
|
|
||||||
public File xml() {
|
|
||||||
return xml_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
package rife.bld.extension;
|
package rife.bld.extension;
|
||||||
|
|
||||||
import org.assertj.core.api.AutoCloseableSoftAssertions;
|
import org.assertj.core.api.AutoCloseableSoftAssertions;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
|
||||||
import org.junit.jupiter.api.Nested;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.EnabledOnOs;
|
import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||||
import org.junit.jupiter.api.condition.OS;
|
import org.junit.jupiter.api.condition.OS;
|
||||||
|
@ -38,16 +36,16 @@ import static org.assertj.core.api.Assertions.assertThatCode;
|
||||||
|
|
||||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
class JacocoReportOperationTest {
|
class JacocoReportOperationTest {
|
||||||
final File csvFile;
|
final File csv;
|
||||||
final File htmlDir;
|
final File html;
|
||||||
final Path tempDir;
|
final Path tempDir;
|
||||||
final File xmlFile;
|
final File xml;
|
||||||
|
|
||||||
JacocoReportOperationTest() throws IOException {
|
JacocoReportOperationTest() throws IOException {
|
||||||
tempDir = Files.createTempDirectory("jacoco-test");
|
tempDir = Files.createTempDirectory("jacoco-test");
|
||||||
csvFile = (new File(tempDir.toFile(), "jacoco.csv"));
|
csv = (new File(tempDir.toFile(), "jacoco.csv"));
|
||||||
htmlDir = (new File(tempDir.toFile(), "html"));
|
html = (new File(tempDir.toFile(), "html"));
|
||||||
xmlFile = (new File(tempDir.toFile(), "jacoco.xml"));
|
xml = (new File(tempDir.toFile(), "jacoco.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deleteOnExit(File folder) {
|
static void deleteOnExit(File folder) {
|
||||||
|
@ -63,7 +61,7 @@ class JacocoReportOperationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledOnOs(OS.LINUX)
|
@EnabledOnOs(OS.LINUX)
|
||||||
void checkAllParams() throws IOException {
|
void checkAllParamsTest() throws IOException {
|
||||||
var supported = List.of("<execfiles>",
|
var supported = List.of("<execfiles>",
|
||||||
"--classfiles",
|
"--classfiles",
|
||||||
"--csv",
|
"--csv",
|
||||||
|
@ -81,339 +79,131 @@ class JacocoReportOperationTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Test
|
||||||
@DisplayName("Execute Tests")
|
void executeFailureTest() {
|
||||||
class ExecuteTests {
|
var op = new JacocoReportOperation().fromProject(new Project());
|
||||||
@Test
|
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
|
||||||
void execute() throws Exception {
|
|
||||||
newJacocoReportOperation().execute();
|
|
||||||
|
|
||||||
assertThat(csvFile).exists();
|
|
||||||
assertThat(htmlDir).isDirectory();
|
|
||||||
assertThat(xmlFile).exists();
|
|
||||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
|
||||||
try (var lines = Files.lines(xmlFile.toPath())) {
|
|
||||||
softly.assertThat(lines.anyMatch(s ->
|
|
||||||
s.contains("<counter type=\"INSTRUCTION\" missed=\"0\" covered=\"3\"/>"))).isTrue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertThat(Path.of(htmlDir.getPath(), "com.example", "Examples.java.html")).exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void executeFailure() {
|
|
||||||
var op = new JacocoReportOperation().fromProject(new Project());
|
|
||||||
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
JacocoReportOperation newJacocoReportOperation() {
|
|
||||||
var op = new JacocoReportOperation()
|
|
||||||
.fromProject(new Project())
|
|
||||||
.csv(csvFile)
|
|
||||||
.html(htmlDir)
|
|
||||||
.xml(xmlFile)
|
|
||||||
.classFiles(new File("src/test/resources/Examples.class"))
|
|
||||||
.sourceFiles(new File("examples/src/main/java"))
|
|
||||||
.execFiles(new File("src/test/resources/jacoco.exec"));
|
|
||||||
|
|
||||||
deleteOnExit(tempDir.toFile());
|
|
||||||
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void executeTest() throws Exception {
|
||||||
|
newJacocoReportOperation().execute();
|
||||||
|
|
||||||
@Nested
|
assertThat(csv).exists();
|
||||||
@DisplayName("Options Tests")
|
assertThat(html).isDirectory();
|
||||||
class OptionsTests {
|
assertThat(xml).exists();
|
||||||
public static final String FOO = "foo";
|
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||||
private final File fooFile = new File(FOO);
|
try (var lines = Files.lines(xml.toPath())) {
|
||||||
|
softly.assertThat(lines.anyMatch(s ->
|
||||||
@Test
|
s.contains("<counter type=\"INSTRUCTION\" missed=\"0\" covered=\"3\"/>"))).isTrue();
|
||||||
void csvAsFile() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.csv(fooFile);
|
|
||||||
assertThat(op.csv()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void csvAsPath() {
|
|
||||||
var fooPath = fooFile.toPath();
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.csv(fooPath);
|
|
||||||
assertThat(op.csv()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void csvAsString() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.csv(FOO);
|
|
||||||
assertThat(op.csv()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void htmlAsFile() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.html(fooFile);
|
|
||||||
assertThat(op.html()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void htmlAsPath() {
|
|
||||||
var fooPath = fooFile.toPath();
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.html(fooPath);
|
|
||||||
assertThat(op.html()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void htmlAsString() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.html(FOO);
|
|
||||||
assertThat(op.html()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void quietIsFalse() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.quiet(false);
|
|
||||||
assertThat(op.isQuiet()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void quietIsTrue() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.quiet(true);
|
|
||||||
assertThat(op.isQuiet()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void reportName() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.name(FOO);
|
|
||||||
assertThat(op.name()).isEqualTo(FOO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void tabWidth() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.tabWidth(4);
|
|
||||||
assertThat(op.tabWidth()).isEqualTo(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void xmlAsFile() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.xml(fooFile);
|
|
||||||
assertThat(op.xml()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void xmlAsPath() {
|
|
||||||
var fooPath = fooFile.toPath();
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.xml(fooPath);
|
|
||||||
assertThat(op.xml()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void xmlAsString() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.xml(FOO);
|
|
||||||
assertThat(op.xml()).isEqualTo(fooFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@DisplayName("Test Tool Options Tests")
|
|
||||||
class TestToolOptionsTests {
|
|
||||||
public static final String BAR = "bar";
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testToolOptionsAsArray() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op = op.testToolOptions(FOO, BAR);
|
|
||||||
assertThat(op.testToolOptions()).contains(FOO, BAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testToolOptionsAsList() {
|
|
||||||
var op = new JacocoReportOperation();
|
|
||||||
op.testToolOptions(List.of(FOO, BAR));
|
|
||||||
assertThat(op.testToolOptions()).contains(FOO, BAR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assertThat(Path.of(html.getPath(), "com.example", "Examples.java.html")).exists();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
JacocoReportOperation newJacocoReportOperation() {
|
||||||
@DisplayName("File Operation Tests")
|
var op = new JacocoReportOperation()
|
||||||
class FilesOperationTests {
|
.fromProject(new Project())
|
||||||
private final File barFile = new File("bar");
|
.csv(csv)
|
||||||
private final File fooFile = new File("foo");
|
.html(html)
|
||||||
private final JacocoReportOperation op = new JacocoReportOperation();
|
.xml(xml)
|
||||||
|
.classFiles(new File("src/test/resources/Examples.class"))
|
||||||
|
.sourceFiles(new File("examples/src/main/java"))
|
||||||
|
.execFiles(new File("src/test/resources/jacoco.exec"));
|
||||||
|
|
||||||
@Nested
|
deleteOnExit(tempDir.toFile());
|
||||||
@DisplayName("Class Files Tests")
|
|
||||||
class ClassFilesTests {
|
|
||||||
@Test
|
|
||||||
void classFilesAsFileArray() {
|
|
||||||
op.classFiles().clear();
|
|
||||||
assertThat(op.classFiles()).isEmpty();
|
|
||||||
op.classFiles(fooFile, barFile);
|
|
||||||
assertThat(op.classFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
return op;
|
||||||
void classFilesAsFileList() {
|
}
|
||||||
op.classFiles().clear();
|
|
||||||
assertThat(op.classFiles()).isEmpty();
|
|
||||||
op.classFiles(List.of(fooFile, barFile));
|
|
||||||
assertThat(op.classFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void classFilesAsPathArray() {
|
void testClassFiles() {
|
||||||
op.classFiles().clear();
|
var foo = new File("foo");
|
||||||
assertThat(op.classFiles()).isEmpty();
|
var bar = new File("bar");
|
||||||
op.classFiles(fooFile.toPath(), barFile.toPath());
|
|
||||||
assertThat(op.classFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
var op = new JacocoReportOperation().classFiles("foo", "bar");
|
||||||
void classFilesAsPathList() {
|
assertThat(op.classFiles()).as("String...").contains(foo, bar);
|
||||||
op.classFiles().clear();
|
op.classFiles().clear();
|
||||||
assertThat(op.classFiles()).isEmpty();
|
|
||||||
op.classFilesPaths(List.of(fooFile.toPath(), barFile.toPath()));
|
|
||||||
assertThat(op.classFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
op = op.classFiles(foo, bar);
|
||||||
void classFilesAsStringArray() {
|
assertThat(op.classFiles()).as("File...").contains(foo, bar);
|
||||||
op.classFiles().clear();
|
op.classFiles().clear();
|
||||||
assertThat(op.classFiles()).isEmpty();
|
|
||||||
op.classFiles("foo", "bar");
|
|
||||||
assertThat(op.classFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
op = op.classFiles(foo.toPath(), bar.toPath());
|
||||||
void classFilesAsStringList() {
|
assertThat(op.classFiles()).as("Path...").contains(foo, bar);
|
||||||
op.classFiles().clear();
|
op.classFiles().clear();
|
||||||
assertThat(op.classFiles()).isEmpty();
|
|
||||||
op.classFilesStrings(List.of("foo", "bar"));
|
|
||||||
assertThat(op.classFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
op = op.classFilesStrings(List.of("foo", "bar"));
|
||||||
@DisplayName("Exec Files Tests")
|
assertThat(op.classFiles()).as("List(String...)").contains(foo, bar);
|
||||||
class ExecFilesTests {
|
op.classFiles().clear();
|
||||||
private final File barFile = new File("bar");
|
|
||||||
private final File fooFile = new File("foo");
|
|
||||||
private final JacocoReportOperation op = new JacocoReportOperation();
|
|
||||||
|
|
||||||
@Test
|
op = op.classFiles(List.of(foo, bar));
|
||||||
void execFilesAsFileArray() {
|
assertThat(op.classFiles()).as("File...").contains(foo, bar);
|
||||||
op.execFiles().clear();
|
op.classFiles().clear();
|
||||||
assertThat(op.execFiles()).isEmpty();
|
|
||||||
op.execFiles(fooFile, barFile);
|
|
||||||
assertThat(op.execFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
op = op.classFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
||||||
void execFilesAsFileList() {
|
assertThat(op.classFiles()).as("Path...").contains(foo, bar);
|
||||||
op.execFiles().clear();
|
op.classFiles().clear();
|
||||||
assertThat(op.execFiles()).isEmpty();
|
}
|
||||||
op.execFiles(List.of(fooFile, barFile));
|
|
||||||
assertThat(op.execFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void execFilesAsPathArray() {
|
void testExecFiles() {
|
||||||
op.execFiles().clear();
|
var foo = new File("foo");
|
||||||
assertThat(op.execFiles()).isEmpty();
|
var bar = new File("bar");
|
||||||
op.execFiles(fooFile.toPath(), barFile.toPath());
|
|
||||||
assertThat(op.execFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
var op = new JacocoReportOperation().execFiles("foo", "bar");
|
||||||
void execFilesAsPathList() {
|
assertThat(op.execFiles()).as("String...").contains(foo, bar);
|
||||||
op.execFiles().clear();
|
op.execFiles().clear();
|
||||||
assertThat(op.execFiles()).isEmpty();
|
|
||||||
op.execFilesPaths(List.of(fooFile.toPath(), barFile.toPath()));
|
|
||||||
assertThat(op.execFiles()).contains(fooFile, barFile);
|
|
||||||
op.execFiles().clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
op = op.execFiles(foo, bar);
|
||||||
void execFilesAsStringArray() {
|
assertThat(op.execFiles()).as("File...").contains(foo, bar);
|
||||||
op.execFiles().clear();
|
op.execFiles().clear();
|
||||||
assertThat(op.execFiles()).isEmpty();
|
|
||||||
op.execFiles("foo", "bar");
|
|
||||||
assertThat(op.execFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
op = op.execFiles(foo.toPath(), bar.toPath());
|
||||||
void execFilesAsStringList() {
|
assertThat(op.execFiles()).as("Path...").contains(foo, bar);
|
||||||
op.execFiles().clear();
|
op.execFiles().clear();
|
||||||
assertThat(op.execFiles()).isEmpty();
|
|
||||||
op.execFilesStrings(List.of("foo", "bar"));
|
|
||||||
assertThat(op.execFiles()).contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
op = op.execFilesStrings(List.of("foo", "bar"));
|
||||||
@DisplayName("Source Files Tests")
|
assertThat(op.execFiles()).as("List(String...)").contains(foo, bar);
|
||||||
class SourceFilesTests {
|
op.execFiles().clear();
|
||||||
private final File barFile = new File("bar");
|
|
||||||
private final File fooFile = new File("foo");
|
|
||||||
private final JacocoReportOperation op = new JacocoReportOperation();
|
|
||||||
|
|
||||||
@Test
|
op = op.execFiles(List.of(foo, bar));
|
||||||
void sourceFilesAsFileArray() {
|
assertThat(op.execFiles()).as("File...").contains(foo, bar);
|
||||||
op.sourceFiles().clear();
|
op.execFiles().clear();
|
||||||
assertThat(op.sourceFiles()).isEmpty();
|
|
||||||
op.sourceFiles(fooFile, barFile);
|
|
||||||
assertThat(op.sourceFiles()).as("File...").contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
op = op.execFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
||||||
void sourceFilesAsFileList() {
|
assertThat(op.execFiles()).as("Path...").contains(foo, bar);
|
||||||
op.sourceFiles().clear();
|
op.execFiles().clear();
|
||||||
assertThat(op.sourceFiles()).isEmpty();
|
}
|
||||||
op.sourceFiles(List.of(fooFile, barFile));
|
|
||||||
assertThat(op.sourceFiles()).as("File...").contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void sourceFilesAsPathList() {
|
void testSourceFiles() {
|
||||||
op.sourceFiles().clear();
|
var foo = new File("foo");
|
||||||
assertThat(op.sourceFiles()).isEmpty();
|
var bar = new File("bar");
|
||||||
op.sourceFilesPaths(List.of(fooFile.toPath(), barFile.toPath()));
|
|
||||||
assertThat(op.sourceFiles()).as("Path...").contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
var op = new JacocoReportOperation().sourceFiles("foo", "bar");
|
||||||
void sourceFilesAsStringArray() {
|
assertThat(op.sourceFiles()).as("String...").contains(foo, bar);
|
||||||
op.sourceFiles().clear();
|
op.sourceFiles().clear();
|
||||||
assertThat(op.sourceFiles()).isEmpty();
|
|
||||||
op.sourceFiles("foo", "bar");
|
|
||||||
assertThat(op.sourceFiles()).as("String...").contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
op = op.sourceFiles(foo, bar);
|
||||||
void sourceFilesAsStringList() {
|
assertThat(op.sourceFiles()).as("File...").contains(foo, bar);
|
||||||
op.sourceFiles().clear();
|
op.sourceFiles().clear();
|
||||||
assertThat(op.sourceFiles()).isEmpty();
|
|
||||||
op.sourceFilesStrings(List.of("foo", "bar"));
|
|
||||||
assertThat(op.sourceFiles()).as("List(String...)").contains(fooFile, barFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
op = op.sourceFiles(foo.toPath(), bar.toPath());
|
||||||
void sourceFilesPathArray() {
|
assertThat(op.sourceFiles()).as("Path...").contains(foo, bar);
|
||||||
op.sourceFiles().clear();
|
op.sourceFiles().clear();
|
||||||
assertThat(op.sourceFiles()).isEmpty();
|
|
||||||
op.sourceFiles(fooFile.toPath(), barFile.toPath());
|
op = op.sourceFilesStrings(List.of("foo", "bar"));
|
||||||
assertThat(op.sourceFiles()).as("Path...").contains(fooFile, barFile);
|
assertThat(op.sourceFiles()).as("List(String...)").contains(foo, bar);
|
||||||
}
|
op.sourceFiles().clear();
|
||||||
}
|
|
||||||
|
op = op.sourceFiles(List.of(foo, bar));
|
||||||
|
assertThat(op.sourceFiles()).as("File...").contains(foo, bar);
|
||||||
|
op.sourceFiles().clear();
|
||||||
|
|
||||||
|
op = op.sourceFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
||||||
|
assertThat(op.sourceFiles()).as("Path...").contains(foo, bar);
|
||||||
|
op.sourceFiles().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue