Cleanup tests
This commit is contained in:
parent
fb3832ace9
commit
95df2d5838
2 changed files with 181 additions and 111 deletions
|
@ -411,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) {
|
||||||
|
@ -422,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) {
|
||||||
|
@ -432,7 +432,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(Path html) {
|
public JacocoReportOperation html(Path html) {
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
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;
|
||||||
|
@ -61,7 +63,7 @@ class JacocoReportOperationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnabledOnOs(OS.LINUX)
|
@EnabledOnOs(OS.LINUX)
|
||||||
void checkAllParamsTest() throws IOException {
|
void checkAllParams() throws IOException {
|
||||||
var supported = List.of("<execfiles>",
|
var supported = List.of("<execfiles>",
|
||||||
"--classfiles",
|
"--classfiles",
|
||||||
"--csv",
|
"--csv",
|
||||||
|
@ -79,29 +81,9 @@ class JacocoReportOperationTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Nested
|
||||||
void executeFailureTest() {
|
@DisplayName("Execute Tests")
|
||||||
var op = new JacocoReportOperation().fromProject(new Project());
|
class ExecuteTests {
|
||||||
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void executeTest() throws Exception {
|
|
||||||
newJacocoReportOperation().execute();
|
|
||||||
|
|
||||||
assertThat(csv).exists();
|
|
||||||
assertThat(html).isDirectory();
|
|
||||||
assertThat(xml).exists();
|
|
||||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
|
||||||
try (var lines = Files.lines(xml.toPath())) {
|
|
||||||
softly.assertThat(lines.anyMatch(s ->
|
|
||||||
s.contains("<counter type=\"INSTRUCTION\" missed=\"0\" covered=\"3\"/>"))).isTrue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertThat(Path.of(html.getPath(), "com.example", "Examples.java.html")).exists();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
JacocoReportOperation newJacocoReportOperation() {
|
JacocoReportOperation newJacocoReportOperation() {
|
||||||
var op = new JacocoReportOperation()
|
var op = new JacocoReportOperation()
|
||||||
.fromProject(new Project())
|
.fromProject(new Project())
|
||||||
|
@ -118,92 +100,180 @@ class JacocoReportOperationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testClassFiles() {
|
void execute() throws Exception {
|
||||||
var foo = new File("foo");
|
newJacocoReportOperation().execute();
|
||||||
var bar = new File("bar");
|
|
||||||
|
|
||||||
var op = new JacocoReportOperation().classFiles("foo", "bar");
|
assertThat(csv).exists();
|
||||||
assertThat(op.classFiles()).as("String...").contains(foo, bar);
|
assertThat(html).isDirectory();
|
||||||
op.classFiles().clear();
|
assertThat(xml).exists();
|
||||||
|
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||||
op = op.classFiles(foo, bar);
|
try (var lines = Files.lines(xml.toPath())) {
|
||||||
assertThat(op.classFiles()).as("File...").contains(foo, bar);
|
softly.assertThat(lines.anyMatch(s ->
|
||||||
op.classFiles().clear();
|
s.contains("<counter type=\"INSTRUCTION\" missed=\"0\" covered=\"3\"/>"))).isTrue();
|
||||||
|
}
|
||||||
op = op.classFiles(foo.toPath(), bar.toPath());
|
}
|
||||||
assertThat(op.classFiles()).as("Path...").contains(foo, bar);
|
assertThat(Path.of(html.getPath(), "com.example", "Examples.java.html")).exists();
|
||||||
op.classFiles().clear();
|
|
||||||
|
|
||||||
op = op.classFilesStrings(List.of("foo", "bar"));
|
|
||||||
assertThat(op.classFiles()).as("List(String...)").contains(foo, bar);
|
|
||||||
op.classFiles().clear();
|
|
||||||
|
|
||||||
op = op.classFiles(List.of(foo, bar));
|
|
||||||
assertThat(op.classFiles()).as("File...").contains(foo, bar);
|
|
||||||
op.classFiles().clear();
|
|
||||||
|
|
||||||
op = op.classFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
|
||||||
assertThat(op.classFiles()).as("Path...").contains(foo, bar);
|
|
||||||
op.classFiles().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testExecFiles() {
|
void executeFailure() {
|
||||||
var foo = new File("foo");
|
var op = new JacocoReportOperation().fromProject(new Project());
|
||||||
var bar = new File("bar");
|
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var op = new JacocoReportOperation().execFiles("foo", "bar");
|
@Nested
|
||||||
assertThat(op.execFiles()).as("String...").contains(foo, bar);
|
@DisplayName("File Operation Tests")
|
||||||
|
class FilesOperationTests {
|
||||||
|
private final File bar = new File("bar");
|
||||||
|
private final File foo = new File("foo");
|
||||||
|
private final JacocoReportOperation op = new JacocoReportOperation();
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@DisplayName("Class Files Tests")
|
||||||
|
class ClassFilesTests {
|
||||||
|
@Test
|
||||||
|
void classFilesAsFileArray() {
|
||||||
|
op.classFiles().clear();
|
||||||
|
op.classFiles(foo, bar);
|
||||||
|
assertThat(op.classFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void classFilesAsFileList() {
|
||||||
|
op.classFiles().clear();
|
||||||
|
op.classFiles(List.of(foo, bar));
|
||||||
|
assertThat(op.classFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void classFilesAsPathArray() {
|
||||||
|
op.classFiles().clear();
|
||||||
|
op.classFiles(foo.toPath(), bar.toPath());
|
||||||
|
assertThat(op.classFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void classFilesAsPathList() {
|
||||||
|
op.classFiles().clear();
|
||||||
|
op.classFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
||||||
|
assertThat(op.classFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void classFilesAsStringArray() {
|
||||||
|
op.classFiles().clear();
|
||||||
|
op.classFiles("foo", "bar");
|
||||||
|
assertThat(op.classFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void classFilesAsStringList() {
|
||||||
|
op.classFiles().clear();
|
||||||
|
op.classFilesStrings(List.of("foo", "bar"));
|
||||||
|
assertThat(op.classFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@DisplayName("Exec Files Tests")
|
||||||
|
class ExecFilesTests {
|
||||||
|
private final File bar = new File("bar");
|
||||||
|
private final File foo = new File("foo");
|
||||||
|
private final JacocoReportOperation op = new JacocoReportOperation();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void execFilesAsFileArray() {
|
||||||
op.execFiles().clear();
|
op.execFiles().clear();
|
||||||
|
op.execFiles(foo, bar);
|
||||||
|
assertThat(op.execFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
op = op.execFiles(foo, bar);
|
@Test
|
||||||
assertThat(op.execFiles()).as("File...").contains(foo, bar);
|
void execFilesAsFileList() {
|
||||||
op.execFiles().clear();
|
op.execFiles().clear();
|
||||||
|
op.execFiles(List.of(foo, bar));
|
||||||
|
assertThat(op.execFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
op = op.execFiles(foo.toPath(), bar.toPath());
|
@Test
|
||||||
assertThat(op.execFiles()).as("Path...").contains(foo, bar);
|
void execFilesAsPathArray() {
|
||||||
op.execFiles().clear();
|
op.execFiles().clear();
|
||||||
|
op.execFiles(foo.toPath(), bar.toPath());
|
||||||
|
assertThat(op.execFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
op = op.execFilesStrings(List.of("foo", "bar"));
|
@Test
|
||||||
assertThat(op.execFiles()).as("List(String...)").contains(foo, bar);
|
void execFilesAsPathList() {
|
||||||
op.execFiles().clear();
|
op.execFiles().clear();
|
||||||
|
op.execFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
||||||
op = op.execFiles(List.of(foo, bar));
|
assertThat(op.execFiles()).contains(foo, bar);
|
||||||
assertThat(op.execFiles()).as("File...").contains(foo, bar);
|
|
||||||
op.execFiles().clear();
|
|
||||||
|
|
||||||
op = op.execFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
|
||||||
assertThat(op.execFiles()).as("Path...").contains(foo, bar);
|
|
||||||
op.execFiles().clear();
|
op.execFiles().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSourceFiles() {
|
void execFilesAsStringArray() {
|
||||||
var foo = new File("foo");
|
op.execFiles().clear();
|
||||||
var bar = new File("bar");
|
op.execFiles("foo", "bar");
|
||||||
|
assertThat(op.execFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
var op = new JacocoReportOperation().sourceFiles("foo", "bar");
|
@Test
|
||||||
|
void execFilesAsStringList() {
|
||||||
|
op.execFiles().clear();
|
||||||
|
op.execFilesStrings(List.of("foo", "bar"));
|
||||||
|
assertThat(op.execFiles()).contains(foo, bar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@DisplayName("Source Files Tests")
|
||||||
|
class SourceFilesTests {
|
||||||
|
private final File bar = new File("bar");
|
||||||
|
private final File foo = new File("foo");
|
||||||
|
private final JacocoReportOperation op = new JacocoReportOperation();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sourceFilesAsFileArray() {
|
||||||
|
op.sourceFiles().clear();
|
||||||
|
op.sourceFiles(foo, bar);
|
||||||
|
assertThat(op.sourceFiles()).as("File...").contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sourceFilesAsFileList() {
|
||||||
|
op.sourceFiles().clear();
|
||||||
|
op.sourceFiles(List.of(foo, bar));
|
||||||
|
assertThat(op.sourceFiles()).as("File...").contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sourceFilesAsPathList() {
|
||||||
|
op.sourceFiles().clear();
|
||||||
|
op.sourceFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
||||||
|
assertThat(op.sourceFiles()).as("Path...").contains(foo, bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sourceFilesAsStringArray() {
|
||||||
|
op.sourceFiles().clear();
|
||||||
|
op.sourceFiles("foo", "bar");
|
||||||
assertThat(op.sourceFiles()).as("String...").contains(foo, bar);
|
assertThat(op.sourceFiles()).as("String...").contains(foo, bar);
|
||||||
op.sourceFiles().clear();
|
}
|
||||||
|
|
||||||
op = op.sourceFiles(foo, bar);
|
@Test
|
||||||
assertThat(op.sourceFiles()).as("File...").contains(foo, bar);
|
void sourceFilesAsStringList() {
|
||||||
op.sourceFiles().clear();
|
op.sourceFiles().clear();
|
||||||
|
op.sourceFilesStrings(List.of("foo", "bar"));
|
||||||
op = op.sourceFiles(foo.toPath(), bar.toPath());
|
|
||||||
assertThat(op.sourceFiles()).as("Path...").contains(foo, bar);
|
|
||||||
op.sourceFiles().clear();
|
|
||||||
|
|
||||||
op = op.sourceFilesStrings(List.of("foo", "bar"));
|
|
||||||
assertThat(op.sourceFiles()).as("List(String...)").contains(foo, bar);
|
assertThat(op.sourceFiles()).as("List(String...)").contains(foo, bar);
|
||||||
op.sourceFiles().clear();
|
}
|
||||||
|
|
||||||
op = op.sourceFiles(List.of(foo, bar));
|
@Test
|
||||||
assertThat(op.sourceFiles()).as("File...").contains(foo, bar);
|
void sourceFilesPathArray() {
|
||||||
op.sourceFiles().clear();
|
op.sourceFiles().clear();
|
||||||
|
op.sourceFiles(foo.toPath(), bar.toPath());
|
||||||
op = op.sourceFilesPaths(List.of(foo.toPath(), bar.toPath()));
|
|
||||||
assertThat(op.sourceFiles()).as("Path...").contains(foo, bar);
|
assertThat(op.sourceFiles()).as("Path...").contains(foo, bar);
|
||||||
op.sourceFiles().clear();
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue