diff --git a/pitest-maven-verification/src/test/java/org/pitest/PitMojoIT.java b/pitest-maven-verification/src/test/java/org/pitest/PitMojoIT.java index 936a741f6..8a4b14233 100755 --- a/pitest-maven-verification/src/test/java/org/pitest/PitMojoIT.java +++ b/pitest-maven-verification/src/test/java/org/pitest/PitMojoIT.java @@ -19,11 +19,7 @@ import org.apache.maven.it.VerificationException; import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.*; import org.junit.rules.TemporaryFolder; import org.junit.rules.TestName; import org.pitest.support.DirectoriesOnlyWalker; @@ -38,10 +34,7 @@ import java.util.Properties; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import static org.junit.Assume.assumeFalse; /** @@ -354,9 +347,21 @@ public void shouldCorrectlyHandleOverrides() throws Exception { buildFilePath(testDir, "target", "site", "pit-reports").exists()); } - @Test(expected = FileNotFoundException.class) + @Test public void shouldReadExclusionsFromSurefireConfig() throws Exception { File testDir = prepare("/pit-surefire-excludes"); + verifier.executeGoal("test"); + verifier.executeGoal("org.pitest:pitest-maven:mutationCoverage"); + + String actual = readResults(testDir); + assertThat(actual) + .contains( + "NotCovered.java"); + } + + @Test(expected = FileNotFoundException.class) + public void shouldNotExecuteWhenSkipTestsFlagActive() throws Exception { + File testDir = prepare("/pit-skipTests-active"); verifier.addCliOption("-DskipTests"); verifier.executeGoal("test"); verifier.executeGoal("org.pitest:pitest-maven:mutationCoverage"); diff --git a/pitest-maven-verification/src/test/resources/pit-skipTests-active/pom.xml b/pitest-maven-verification/src/test/resources/pit-skipTests-active/pom.xml new file mode 100644 index 000000000..d72cd1a51 --- /dev/null +++ b/pitest-maven-verification/src/test/resources/pit-skipTests-active/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + com.example + junit-categories-check + jar + 1.0-SNAPSHOT + skipTests-active + + + junit + junit + 4.11 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.4 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + **/FailingTest.java + **/BadTest.java + + + + + org.pitest + pitest-maven + ${pit.version} + + true + + XML + + +CLASSLIMIT(limit[1]) + false + + NEGATE_CONDITIONALS + + true + + + + + + diff --git a/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/main/java/com/example/Covered.java b/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/main/java/com/example/Covered.java new file mode 100644 index 000000000..ea7b74b51 --- /dev/null +++ b/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/main/java/com/example/Covered.java @@ -0,0 +1,13 @@ +package com.example; + +public class Covered { + + public static int someCode(int i) { + if ( i == 0 ) { + return 1; + } + + return 1; + } + +} diff --git a/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/main/java/com/example/NotCovered.java b/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/main/java/com/example/NotCovered.java new file mode 100644 index 000000000..ac93a193e --- /dev/null +++ b/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/main/java/com/example/NotCovered.java @@ -0,0 +1,17 @@ +package com.example; + +public class NotCovered { + + public static int someCode(int i) { + if ( i == 0 ) { + return 1; + } + + if ( i == 2 ) { + return 42; + } + + return i; + } + +} diff --git a/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/test/java/com/example/AnotherTest.java b/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/test/java/com/example/AnotherTest.java new file mode 100644 index 000000000..7a5871b53 --- /dev/null +++ b/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/test/java/com/example/AnotherTest.java @@ -0,0 +1,21 @@ +package com.example; + +import java.util.Arrays; +import java.util.Collection; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class AnotherTest { + + @Test + public void aTest() { + assertEquals(1, Covered.someCode(0)); + } + + @Test + public void anotherTest() { + assertEquals(1, Covered.someCode(1)); + } + +} diff --git a/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/test/java/com/example/BadTest.java b/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/test/java/com/example/BadTest.java new file mode 100644 index 000000000..2d93c7688 --- /dev/null +++ b/pitest-maven-verification/src/test/resources/pit-skipTests-active/src/test/java/com/example/BadTest.java @@ -0,0 +1,16 @@ +package com.example; + +import java.util.Arrays; +import java.util.Collection; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class BadTest { + + @Test + public void aTest() { + assertEquals(1, 2); + } + +}