-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix JUnit5 reporting when tests are executed in parallel
- Loading branch information
1 parent
e99f11e
commit 5c627f9
Showing
9 changed files
with
300 additions
and
21 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2252JUnit5IT.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,61 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.maven.surefire.its.jiras; | ||
|
||
import org.apache.maven.surefire.its.fixture.OutputValidator; | ||
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; | ||
import org.junit.Test; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
/** | ||
* Integration tests for SUREFIRE-2252 | ||
*/ | ||
public class Surefire2252JUnit5IT extends SurefireJUnit4IntegrationTestCase { | ||
@Test | ||
public void testJUnit5() throws Exception { | ||
unpack("surefire-2252-junit5-parallel") | ||
.executeTest() | ||
.verifyTextInLog( | ||
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider") | ||
.assertThatLogLine(containsString("Tests run: 1, Failures: 0, Errors: 0, Skipped: 0"), is(2)); | ||
} | ||
|
||
@Test | ||
public void testJUnit5Xml() { | ||
OutputValidator validator = | ||
unpack("surefire-2252-junit5-parallel-xml").executeTest().verifyErrorFree(2); | ||
|
||
validator | ||
.getSurefireReportsFile("TEST-pkg.domain.AxTest.xml", UTF_8) | ||
.assertContainsText("tests=\"1\"") | ||
.assertContainsText("errors=\"0\"") | ||
.assertContainsText("skipped=\"0\"") | ||
.assertContainsText("failures=\"0\""); | ||
|
||
validator | ||
.getSurefireReportsFile("TEST-pkg.domain.BxTest.xml", UTF_8) | ||
.assertContainsText("tests=\"1\"") | ||
.assertContainsText("errors=\"0\"") | ||
.assertContainsText("skipped=\"0\"") | ||
.assertContainsText("failures=\"0\""); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
surefire-its/src/test/resources/surefire-2252-junit5-parallel-xml/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,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>surefire-2252-junit5-parallel</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>${java.specification.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.specification.version}</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.10.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.3.2-SNAPSHOT</version> | ||
<configuration> | ||
<properties> | ||
<configurationParameters> | ||
junit.jupiter.execution.parallel.enabled = true | ||
junit.jupiter.execution.parallel.mode.default = same_thread | ||
junit.jupiter.execution.parallel.mode.classes.default = concurrent | ||
</configurationParameters> | ||
</properties> | ||
<threadCount>2</threadCount> | ||
<reportFormat>xml</reportFormat> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
|
||
</project> |
9 changes: 9 additions & 0 deletions
9
...src/test/resources/surefire-2252-junit5-parallel-xml/src/test/java/pkg/domain/AxTest.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,9 @@ | ||
package pkg.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class AxTest { | ||
@Test | ||
void test() { | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...src/test/resources/surefire-2252-junit5-parallel-xml/src/test/java/pkg/domain/BxTest.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,9 @@ | ||
package pkg.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class BxTest { | ||
@Test | ||
void test() { | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
surefire-its/src/test/resources/surefire-2252-junit5-parallel/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,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>surefire-2252-junit5-parallel</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>${java.specification.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.specification.version}</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.10.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.3.2-SNAPSHOT</version> | ||
<configuration> | ||
<properties> | ||
<configurationParameters> | ||
junit.jupiter.execution.parallel.enabled = true | ||
junit.jupiter.execution.parallel.mode.default = same_thread | ||
junit.jupiter.execution.parallel.mode.classes.default = concurrent | ||
</configurationParameters> | ||
</properties> | ||
<threadCount>2</threadCount> | ||
<reportFormat>plain</reportFormat> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
|
||
</project> |
9 changes: 9 additions & 0 deletions
9
...its/src/test/resources/surefire-2252-junit5-parallel/src/test/java/pkg/domain/AxTest.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,9 @@ | ||
package pkg.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class AxTest { | ||
@Test | ||
void test() { | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...its/src/test/resources/surefire-2252-junit5-parallel/src/test/java/pkg/domain/BxTest.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,9 @@ | ||
package pkg.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class BxTest { | ||
@Test | ||
void test() { | ||
} | ||
} |
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
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