-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1014 from hcoles/bug/missing-plugin-reporting
check for junit4 on classpath before loading plugin
- Loading branch information
Showing
9 changed files
with
191 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
pitest-maven-verification/src/test/resources/pit-missing-test-plugin/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.example</groupId> | ||
<artifactId>junit-categories-check</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>missing-test-plugin</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>5.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.10.1</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.pitest</groupId> | ||
<artifactId>pitest-maven</artifactId> | ||
<version>${pit.version}</version> | ||
<configuration> | ||
<exportLineCoverage>true</exportLineCoverage> | ||
<outputFormats><value>XML</value></outputFormats> | ||
<timestampedReports>false</timestampedReports> | ||
<targetTests><param>com.example.*</param></targetTests> | ||
<targetClasses><param>com.example*</param></targetClasses> | ||
<verbose>true</verbose> | ||
<features>+CLASSLIMIT(limit[6])</features> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
...ication/src/test/resources/pit-missing-test-plugin/src/main/java/com/example/Covered.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example; | ||
|
||
public class Covered { | ||
|
||
public static int someCode(int i) { | ||
if ( i == 0 ) { | ||
return 1; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...tion/src/test/resources/pit-missing-test-plugin/src/main/java/com/example/NotCovered.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...ification/src/test/resources/pit-missing-test-plugin/src/test/java/com/example/ATest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ATest { | ||
|
||
@Test | ||
public void aTest() { | ||
assertEquals(1, NotCovered.someCode(0)); | ||
} | ||
|
||
@Test | ||
public void anotherTest() { | ||
assertEquals(42, NotCovered.someCode(2)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...ion/src/test/resources/pit-missing-test-plugin/src/test/java/com/example/AnotherTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class AnotherTest { | ||
|
||
@Test | ||
public void aTest() { | ||
assertEquals(1, Covered.someCode(0)); | ||
} | ||
|
||
@Test | ||
public void anotherTest() { | ||
assertEquals(1, Covered.someCode(1)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
pitest/src/main/java/org/pitest/junit/NullConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.pitest.junit; | ||
|
||
import org.pitest.help.PitHelpError; | ||
import org.pitest.testapi.Configuration; | ||
import org.pitest.testapi.TestSuiteFinder; | ||
import org.pitest.testapi.TestUnitFinder; | ||
|
||
import java.util.Collections; | ||
import java.util.Optional; | ||
|
||
public class NullConfiguration implements Configuration { | ||
@Override | ||
public TestUnitFinder testUnitFinder() { | ||
return c -> Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public TestSuiteFinder testSuiteFinder() { | ||
return c -> Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public Optional<PitHelpError> verifyEnvironment() { | ||
return Optional.empty(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
pitest/src/test/java/org/pitest/junit/NullConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.pitest.junit; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class NullConfigurationTest { | ||
|
||
NullConfiguration underTest = new NullConfiguration(); | ||
|
||
@Test | ||
public void findsNoTests() { | ||
assertThat(underTest.testUnitFinder().findTestUnits(this.getClass())).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void findsNoSuites() { | ||
assertThat(underTest.testSuiteFinder().apply(this.getClass())).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void passesVerification() { | ||
assertThat(underTest.verifyEnvironment()).isEmpty(); | ||
} | ||
} |