Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Aug 31, 2023
1 parent 3210364 commit ef570b7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/bld/java/rife/bld/extension/PitestOperationBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
import static rife.bld.dependencies.Repository.RIFE2_RELEASES;
import static rife.bld.dependencies.Scope.*;
import static rife.bld.dependencies.Scope.compile;
import static rife.bld.dependencies.Scope.test;
import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;

public class PitestOperationBuild extends Project {
Expand All @@ -44,6 +45,9 @@ public PitestOperationBuild() {
scope(compile)
.include(dependency("com.uwyn.rife2", "bld", version(1, 7, 2)));
scope(test)
.include(dependency("org.pitest", "pitest", version(1, 14, 4)))
.include(dependency("org.pitest", "pitest-command-line", version(1, 14, 4)))
.include(dependency("org.pitest", "pitest-junit5-plugin", version(1,2, 0)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 0)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 0)))
.include(dependency("org.assertj:assertj-joda-time:2.2.0"));
Expand Down
27 changes: 24 additions & 3 deletions src/test/java/rife/bld/extension/PitestOperationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
import rife.bld.Project;
import rife.bld.WebProject;

import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static rife.bld.extension.PitestOperation.*;

class PitestOperationTest {
Expand Down Expand Up @@ -109,8 +113,8 @@ void excludedClasses() {

op = new PitestOperation()
.fromProject(new Project())
.excludedClasses(List.of(FOO, BAR));
assertThat(op.options.get("--excludedClasses")).as(AS_LIST).isEqualTo(FOOBAR);
.excludedClasses(Set.of(FOO, BAR));
assertThat(op.options.get("--excludedClasses")).as("as set").contains(FOO).contains(BAR).contains(",");
}

@Test
Expand Down Expand Up @@ -149,7 +153,24 @@ void excludedTests() {
op = new PitestOperation()
.fromProject(new Project())
.excludedTests(List.of(FOO, BAR));
assertThat(op.options.get("--excludedTests")).as(AS_LIST).isEqualTo(FOOBAR);
assertThat(op.options.get("--excludedTests")).as("as list").isEqualTo(FOOBAR);
}

@Test
void execute() throws IOException {
var tmpDir = Files.createTempDirectory("bld-pitest");
tmpDir.toFile().deleteOnExit();
var op = new PitestOperation().
fromProject(new WebProject())
.reportDir(tmpDir.toAbsolutePath().toString())
.targetClasses("com.example.*")
.targetTests("com.example.*")
.verbose(true)
.failWhenNoMutations(false)
.sourceDirs("examples/src");

assertThatCode(op::execute).doesNotThrowAnyException();
assertThat(tmpDir).isEmptyDirectory();
}

@Test
Expand Down

0 comments on commit ef570b7

Please sign in to comment.