-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check for junit4 on classpath before loading plugin #1014
Merged
+191
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to test the error message or something else here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't one at the moment - everything runs without finding tests as there are no applicable test plugins. Just pulling testng support out into an external plugin before fixing that.