This is an automated email from the ASF dual-hosted git repository. olamy pushed a commit to branch SUREFIRE-1643-it-test in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit cbb6c68ba66f16eefd71218cfb3537dcf63bf92f Author: Olivier Lamy <ol...@apache.org> AuthorDate: Tue Mar 18 18:21:58 2025 +1000 Test IT test for SUREFIRE-1643 Signed-off-by: Olivier Lamy <ol...@apache.org> --- .../maven/surefire/its/jiras/Surefire1643IT.java | 73 ++++++++++++ .../surefire-1643-parallel-junit5/.mvn/jvm.config | 0 .../.mvn/maven.config | 0 .../surefire-1643-parallel-junit5/pom.xml | 122 +++++++++++++++++++++ .../src/main/java/io/olamy/App.java | 10 ++ .../src/test/java/io/olamy/App1Test.java | 30 +++++ .../src/test/java/io/olamy/App2Test.java | 30 +++++ .../src/test/java/io/olamy/App3Test.java | 30 +++++ .../src/test/java/io/olamy/App4Test.java | 30 +++++ .../src/test/java/io/olamy/App5Test.java | 30 +++++ 10 files changed, 355 insertions(+) diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1643IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1643IT.java new file mode 100644 index 000000000..de2c57df5 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1643IT.java @@ -0,0 +1,73 @@ +/* + * 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.apache.maven.surefire.its.fixture.TestFile; +import org.junit.Test; + +/** + * + */ +@SuppressWarnings("checkstyle:magicnumber") +public class Surefire1643IT extends SurefireJUnit4IntegrationTestCase { + @Test + public void shouldNotMixResults() { + OutputValidator outputValidator = unpack("surefire-1643-parallel-junit5") + .executeTest() + .verifyTextInLog("BUILD FAILURE") + .assertTestSuiteResults(15, 0, 4, 0); + + TestFile xmlReportFile = outputValidator.getSurefireReportsXmlFile("TEST-io.olamy.App1Test.xml"); + xmlReportFile + .assertNotContainsText("App2Test") + .assertNotContainsText("App3Test") + .assertNotContainsText("App4Test") + .assertNotContainsText("App5Test"); + + xmlReportFile = outputValidator.getSurefireReportsXmlFile("TEST-io.olamy.App2Test.xml"); + xmlReportFile + .assertNotContainsText("App1Test") + .assertNotContainsText("App3Test") + .assertNotContainsText("App4Test") + .assertNotContainsText("App5Test"); + + xmlReportFile = outputValidator.getSurefireReportsXmlFile("TEST-io.olamy.App3Test.xml"); + xmlReportFile + .assertNotContainsText("App1Test") + .assertNotContainsText("App2Test") + .assertNotContainsText("App4Test") + .assertNotContainsText("App5Test"); + + xmlReportFile = outputValidator.getSurefireReportsXmlFile("TEST-io.olamy.App4Test.xml"); + xmlReportFile + .assertNotContainsText("App1Test") + .assertNotContainsText("App2Test") + .assertNotContainsText("App3Test") + .assertNotContainsText("App5Test"); + + xmlReportFile = outputValidator.getSurefireReportsXmlFile("TEST-io.olamy.App5Test.xml"); + xmlReportFile + .assertNotContainsText("App1Test") + .assertNotContainsText("App2Test") + .assertNotContainsText("App3Test") + .assertNotContainsText("App4Test"); + } +} diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/.mvn/jvm.config b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/.mvn/jvm.config new file mode 100644 index 000000000..e69de29bb diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/.mvn/maven.config b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/.mvn/maven.config new file mode 100644 index 000000000..e69de29bb diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/pom.xml b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/pom.xml new file mode 100644 index 000000000..cdb4dd780 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/pom.xml @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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.apache.maven.plugins.surefire</groupId> + <artifactId>junit-platform-1.0.0</artifactId> + <version>1.0</version> + <name>[SUREFIRE-1643] JUnit 5: Parallel Test mixed</name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + <junit.jupiter.execution.parallel.config.fixed.parallelism>2</junit.jupiter.execution.parallel.config.fixed.parallelism> + <junit.jupiter.execution.parallel.config.strategy>fixed</junit.jupiter.execution.parallel.config.strategy> + <junit.jupiter.execution.parallel.enabled>true</junit.jupiter.execution.parallel.enabled> + <junit.jupiter.execution.parallel.mode.classes.default>concurrent</junit.jupiter.execution.parallel.mode.classes.default> + <junit.jupiter.execution.parallel.mode.default>same_thread</junit.jupiter.execution.parallel.mode.default> + <junit.jupiter.extensions.autodetection.enabled>true</junit.jupiter.extensions.autodetection.enabled> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.junit</groupId> + <artifactId>junit-bom</artifactId> + <version>5.9.1</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> + <plugins> + <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>3.4.0</version> + </plugin> + <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>3.3.1</version> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.13.0</version> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>3.5.3-SNAPSHOT</version> + <configuration> + <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory" /> + <trimStackTrace>false</trimStackTrace> + <rerunFailingTestsCount>1</rerunFailingTestsCount> + <forkedProcessTimeoutInSeconds>3600</forkedProcessTimeoutInSeconds> + <failIfNoTests>false</failIfNoTests> + <forkCount>1</forkCount> + <reuseForks>true</reuseForks> + <!-- to work around crash at https://github.com/junit-team/junit5/issues/801 --> + <!-- order can be different depending on os jvm so let's force it --> + <runOrder>alphabetical</runOrder> + + <!-- The LC_ALL env variable must have some UTF variant otherwise creating and/or reading files with non-ascii names doesn't work --> + <environmentVariables> + <LC_ALL>en_US.UTF-8</LC_ALL> + </environmentVariables> + <argLine>-Xms1g</argLine> + <properties> + <configurationParameters>junit.jupiter.execution.parallel.enabled=${junit.jupiter.execution.parallel.enabled} + junit.jupiter.execution.parallel.mode.default=${junit.jupiter.execution.parallel.mode.default} + junit.jupiter.execution.parallel.mode.classes.default=${junit.jupiter.execution.parallel.mode.classes.default} + junit.jupiter.execution.parallel.config.strategy=${junit.jupiter.execution.parallel.config.strategy} + junit.jupiter.execution.parallel.config.fixed.parallelism=${junit.jupiter.execution.parallel.config.fixed.parallelism} + junit.jupiter.extensions.autodetection.enabled=${junit.jupiter.extensions.autodetection.enabled}</configurationParameters> + </properties> + <statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter"> + <disable>false</disable> + <usePhrasedFileName>false</usePhrasedFileName> + <usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName> + <usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName> + <usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName> + </statelessTestsetReporter> + <consoleOutputReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5ConsoleOutputReporter"> + <disable>false</disable> + <encoding>UTF-8</encoding> + <usePhrasedFileName>false</usePhrasedFileName> + </consoleOutputReporter> + <statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoReporter"> + <disable>false</disable> + <usePhrasedFileName>false</usePhrasedFileName> + <usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning> + <usePhrasedClassNameInTestCaseSummary>true</usePhrasedClassNameInTestCaseSummary> + </statelessTestsetInfoReporter> + </configuration> + </plugin> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>3.4.2</version> + </plugin> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <version>3.1.2</version> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <version>3.1.2</version> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/main/java/io/olamy/App.java b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/main/java/io/olamy/App.java new file mode 100644 index 000000000..5354cd8a6 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/main/java/io/olamy/App.java @@ -0,0 +1,10 @@ +package io.olamy; + +/** + * Hello world! + */ +public class App { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App1Test.java b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App1Test.java new file mode 100644 index 000000000..290400446 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App1Test.java @@ -0,0 +1,30 @@ +package io.olamy; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/** + * Unit test for simple App. + */ +public class App1Test { + + @Test + public void app1One() throws Throwable { + Thread.sleep(2000); + assertTrue(true); + } + + @Test + public void app1Two() throws Throwable { + Thread.sleep(2000); + assertTrue(true); + } + + @Test + public void app1Three() throws Throwable { + Thread.sleep(2000); + assertTrue(false); + } + +} diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App2Test.java b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App2Test.java new file mode 100644 index 000000000..65d916540 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App2Test.java @@ -0,0 +1,30 @@ +package io.olamy; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Unit test for simple App. + */ +public class App2Test { + + @Test + public void app2One() throws Throwable { + Thread.sleep(3000); + assertTrue(true); + } + + @Test + public void app2Two() throws Throwable { + Thread.sleep(1000); + assertTrue(true); + } + + @Test + public void app2Three() throws Throwable { + Thread.sleep(2000); + assertTrue(true); + } + +} diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App3Test.java b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App3Test.java new file mode 100644 index 000000000..3835e479c --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App3Test.java @@ -0,0 +1,30 @@ +package io.olamy; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Unit test for simple App. + */ +public class App3Test { + + @Test + public void app3One() throws Throwable { + Thread.sleep(500); + assertTrue(true); + } + + @Test + public void app3Two() throws Throwable { + Thread.sleep(7000); + assertTrue(false); + } + + @Test + public void app3Three() throws Throwable { + Thread.sleep(1000); + assertTrue(false); + } + +} diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App4Test.java b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App4Test.java new file mode 100644 index 000000000..a4831a1c0 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App4Test.java @@ -0,0 +1,30 @@ +package io.olamy; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Unit test for simple App. + */ +public class App4Test { + + @Test + public void app4One() throws Throwable { + Thread.sleep(500); + assertTrue(true); + } + + @Test + public void app4Two() throws Throwable { + Thread.sleep(7000); + assertTrue(true); + } + + @Test + public void app4Three() throws Throwable { + Thread.sleep(1000); + assertTrue(true); + } + +} diff --git a/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App5Test.java b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App5Test.java new file mode 100644 index 000000000..7ff884e95 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1643-parallel-junit5/src/test/java/io/olamy/App5Test.java @@ -0,0 +1,30 @@ +package io.olamy; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Unit test for simple App. + */ +public class App5Test { + + @Test + public void app5One() throws Throwable { + Thread.sleep(500); + assertTrue(true); + } + + @Test + public void app5Two() throws Throwable { + Thread.sleep(200); + assertTrue(false); + } + + @Test + public void app5Three() throws Throwable { + Thread.sleep(1000); + assertTrue(true); + } + +}