Skip to content

Commit 9010488

Browse files
authored
Merge branch 'master' into emptyGroups
2 parents 73e3069 + 1b6cf24 commit 9010488

File tree

4 files changed

+45
-27
lines changed

4 files changed

+45
-27
lines changed

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ Adds support to pitest for JUnit 5 platform test engines, e.g. Jupiter, Cucumber
66

77
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.pitest/pitest-junit5-plugin/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/org.pitest/pitest-junit5-plugin)
88

9+
Releases 1.2.1 and 1.2.2 requires pitest 1.15.2 or above.
10+
911
Release 1.2.0 requires pitest 1.14.0 or above.
1012

11-
When used with the pitest-maven plugin, it will automatically work with JUnit platform 1.5.0 to 1.10.0-M1 (and probably above).
13+
When used with the pitest-maven plugin, or version 1.15.0 of the gradle plugin, it will automatically work with JUnit platform 1.5.0 to 1.10.0-M1 (and probably above).
1214

13-
When used with the pitest gradle plugin, it will automatically work with JUnit platform 1.9.2. To work with other versions an explicit dependency
14-
on junit-platform-launcher must be added to the project under test.
15+
When used with earlier versions of the pitest gradle plugin a dependency must be added to a compatible version of junit-platform-launcher. Depending on how the gradle project is configured the must be added wither a scope of either pitest, or a testImplementation.
1516

1617
Older versions of the plugin must be matched to both the pitest and junit version in use as below.
1718

@@ -39,12 +40,12 @@ To activate the plugin it must be placed on the classpath of the pitest tool (**
3940
<plugin>
4041
<groupId>org.pitest</groupId>
4142
<artifactId>pitest-maven</artifactId>
42-
<version>1.10.3</version>
43+
<version>1.18.2</version>
4344
<dependencies>
4445
<dependency>
4546
<groupId>org.pitest</groupId>
4647
<artifactId>pitest-junit5-plugin</artifactId>
47-
<version>1.1.1</version>
48+
<version>1.2.2</version>
4849
</dependency>
4950
</dependencies>
5051
</plugin>
@@ -57,13 +58,13 @@ For Pitest configuration options, have a look at http://pitest.org/quickstart/ma
5758
```
5859
plugins {
5960
id 'java'
60-
id 'info.solidsoft.pitest' version '1.7.4'
61+
id 'info.solidsoft.pitest' version '1.15.0'
6162
}
6263
6364
pitest {
6465
//adds dependency to org.pitest:pitest-junit5-plugin and sets "testPlugin" to "junit5"
65-
junit5PluginVersion = '1.1.1'
66-
pitestVersion = '1.10.3'
66+
junit5PluginVersion = '1.2.2'
67+
pitestVersion = '1.18.2'
6768
// ...
6869
}
6970
```
@@ -72,6 +73,18 @@ See [gradle-pitest-plugin documentation](https://github.com/szpak/gradle-pitest-
7273

7374
## Release Notes
7475

76+
### 1.2.2
77+
78+
* #109 Set platform-launcher dependency to provided
79+
80+
The pitest maven and gradle plugins now automatically resolve the correct version of platform launcher at
81+
runtime. The built against version of platform-launcher was however being included as a transative dependency sometimes
82+
causing a conflict at runtime.
83+
84+
### 1.2.1
85+
86+
* #103 Report errors and failures during scan stage
87+
7588
### 1.1.1
7689

7790
* #73 Automatically disable parallel mode

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<junit.platform.version>1.9.2</junit.platform.version>
2424
<junit.version>5.9.2</junit.version>
2525
<mockito.version>2.7.6</mockito.version>
26-
<pitest.version>1.9.0</pitest.version>
26+
<pitest.version>1.15.2</pitest.version>
2727
<cucumber.version>5.0.0</cucumber.version>
2828
<spock.version>2.3-groovy-4.0</spock.version>
2929
<groovy.version>4.0.11</groovy.version>
@@ -169,6 +169,7 @@
169169
<groupId>org.junit.platform</groupId>
170170
<artifactId>junit-platform-launcher</artifactId>
171171
<version>${junit.platform.version}</version>
172+
<scope>provided</scope>
172173
</dependency>
173174
<dependency>
174175
<groupId>org.junit.jupiter</groupId>
@@ -238,7 +239,7 @@
238239
<plugin>
239240
<groupId>org.jacoco</groupId>
240241
<artifactId>jacoco-maven-plugin</artifactId>
241-
<version>0.8.5</version>
242+
<version>0.8.11</version>
242243
<executions>
243244
<execution>
244245
<goals>

src/main/java/org/pitest/junit5/JUnit5TestUnitFinder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,11 @@ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult
131131
if (!identifiers.contains(testIdentifier)) {
132132
identifiers.add(testIdentifier);
133133
}
134-
l.executionFinished(new Description(testIdentifier.getUniqueId(), testClass), false);
134+
l.executionFinished(new Description(testIdentifier.getUniqueId(), testClass)
135+
, false, testExecutionResult.getThrowable().orElse(null));
135136
} else if (testIdentifier.isTest()) {
136-
l.executionFinished(new Description(testIdentifier.getUniqueId(), testClass), true);
137+
l.executionFinished(new Description(testIdentifier.getUniqueId(), testClass)
138+
, true);
137139
}
138140
}
139141

src/test/java/org/pitest/junit5/JUnit5TestUnitFinderTest.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.assertj.core.api.Assertions.assertThat;
2020

2121
import org.junit.jupiter.api.Test;
22+
import org.opentest4j.AssertionFailedError;
2223
import org.pitest.junit5.cucumber.RunCucumberTest;
2324
import org.pitest.junit5.repository.AbstractTestClass;
2425
import org.pitest.junit5.repository.InterfaceTestClass;
@@ -67,9 +68,11 @@
6768
import org.pitest.testapi.TestGroupConfig;
6869
import org.pitest.testapi.TestUnit;
6970
import org.pitest.testapi.TestUnitExecutionListener;
71+
import org.spockframework.runtime.ConditionNotSatisfiedError;
7072

7173
import java.util.ArrayList;
7274
import java.util.List;
75+
import java.util.function.Predicate;
7376
import java.util.stream.Collectors;
7477

7578
/**
@@ -149,12 +152,14 @@ void detectsFailingTests() {
149152
void detectsFailingSpockTests() {
150153
findsAndRunsNTests(1, TestSpecWithFailingFeature.class);
151154
nTestsFails(1, TestSpecWithFailingFeature.class);
155+
errorIsRecorded(t -> t instanceof ConditionNotSatisfiedError, TestSpecWithFailingFeature.class);
152156
}
153157

154158
@Test
155159
void detectsErroringTestsWhenPassingTestsPresent() {
156160
nTestsPass(2, TestClassWithMixedPassAndFail.class);
157161
nTestsFails(2, TestClassWithMixedPassAndFail.class);
162+
errorIsRecorded(t -> t instanceof RuntimeException, TestClassWithMixedPassAndFail.class);
158163
}
159164

160165
@Test
@@ -333,6 +338,7 @@ void findsAndRunsTestsWithSetupSpec() {
333338
@Test
334339
void findsAndRunsTestsWithFailingAfterAll() {
335340
findsAndRunsNTests(2, TestClassWithFailingAfterAll.class);
341+
errorIsRecorded(t -> t instanceof AssertionFailedError, TestClassWithFailingAfterAll.class);
336342
}
337343

338344
@Test
@@ -379,6 +385,11 @@ private void nTestsFails(int n, Class<?> clazz) {
379385
assertThat(l.failed).hasSize(n);
380386
}
381387

388+
private void errorIsRecorded(Predicate<Throwable> p, Class<?> clazz) {
389+
RecordingListener l = run(basicConfig(), clazz);
390+
assertThat(l.errors).anyMatch(p);
391+
}
392+
382393
private RecordingListener run(JUnit5TestUnitFinder underTest, Class<?> clazz) {
383394
RecordingListener l = new RecordingListener();
384395
underTest.findTestUnits(clazz, l);
@@ -395,33 +406,24 @@ class RecordingListener implements TestUnitExecutionListener {
395406
List<Description> started = new ArrayList<>();
396407
List<Description> failed = new ArrayList<>();
397408
List<Description> passed = new ArrayList<>();
398-
TestUnitExecutionListener l = new TestUnitExecutionListener() {
399-
@Override
400-
public void executionStarted(Description description) {
401-
started.add(description);
402-
}
403409

404-
@Override
405-
public void executionFinished(Description description, boolean pass) {
406-
if (pass) {
407-
passed.add(description);
408-
} else {
409-
failed.add(description);
410-
}
411-
}
412-
};
410+
List<Throwable> errors = new ArrayList<>();
413411

414412
@Override
415413
public void executionStarted(Description description) {
416414
started.add(description);
417415
}
418416

419417
@Override
420-
public void executionFinished(Description description, boolean pass) {
418+
public void executionFinished(Description description, boolean pass, Throwable optional) {
421419
if (pass) {
422420
passed.add(description);
423421
} else {
424422
failed.add(description);
425423
}
424+
425+
if (optional != null) {
426+
errors.add(optional);
427+
}
426428
}
427429
}

0 commit comments

Comments
 (0)