[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r193647689 ## File path: surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java ## @@ -0,0 +1,272 @@ +package org.apache.maven.surefire.junitplatform; + +/* + * 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. + */ + +import static org.apache.maven.surefire.report.SimpleReportEntry.ignored; +import static org.junit.platform.engine.TestExecutionResult.Status.ABORTED; +import static org.junit.platform.engine.TestExecutionResult.Status.FAILED; + +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.maven.surefire.report.PojoStackTraceWriter; +import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.SimpleReportEntry; +import org.apache.maven.surefire.report.StackTraceWriter; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.engine.TestSource; +import org.junit.platform.engine.support.descriptor.ClassSource; +import org.junit.platform.engine.support.descriptor.MethodSource; +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestIdentifier; +import org.junit.platform.launcher.TestPlan; +import org.junit.platform.launcher.listeners.LegacyReportingUtils; + +/** + * @since 2.22.0 + */ +final class RunListenerAdapter +implements TestExecutionListener +{ + +private final RunListener runListener; + +private TestPlan testPlan; + +private Set testSetNodes = ConcurrentHashMap.newKeySet(); + +RunListenerAdapter( RunListener runListener ) +{ +this.runListener = runListener; +} + +@Override +public void testPlanExecutionStarted( TestPlan testPlan ) +{ +updateTestPlan( testPlan ); +} + +@Override +public void testPlanExecutionFinished( TestPlan testPlan ) +{ +updateTestPlan( null ); +} + +@Override +public void executionStarted( TestIdentifier testIdentifier ) +{ +if ( testIdentifier.isContainer() +&& testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent() ) +{ +startTestSetIfPossible( testIdentifier ); +} +if ( testIdentifier.isTest() ) +{ +ensureTestSetStarted( testIdentifier ); +runListener.testStarting( createReportEntry( testIdentifier ) ); +} +} + +@Override +public void executionSkipped( TestIdentifier testIdentifier, String reason ) +{ +ensureTestSetStarted( testIdentifier ); +String source = getLegacyReportingClassName( testIdentifier ); +runListener.testSkipped( ignored( source, getLegacyReportingName( testIdentifier ), reason ) ); +completeTestSetIfNecessary( testIdentifier ); +} + +@Override +public void executionFinished( +TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ) +{ +if ( testExecutionResult.getStatus() == ABORTED ) +{ +runListener.testAssumptionFailure( createReportEntry( testIdentifier, testExecutionResult ) ); +} +else if ( testExecutionResult.getStatus() == FAILED ) +{ +reportFailedTest( testIdentifier, testExecutionResult ); +} +else if ( testIdentifier.isTest() ) +{ +runListener.testSucceeded( createReportEntry( testIdentifier ) ); +} +completeTestSetIfNecessary( testIdentifier ); +} + +private void updateTestPlan( TestPlan testPlan ) +{ +this.testPlan = testPlan; +testSetNodes.clear(); +} + +private void ensureTestSetStarted( TestIdentifier testIdentifier ) +{ +if ( isTestSetStarted( testIdentifier ) ) +{ +return; +} +if ( testIdentifier.isTest() ) +{ +startTestSet( testPlan.getParent( testIdentifier ).orElse( testIdentifier ) ); +} +
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r192987675 ## File path: surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java ## @@ -0,0 +1,272 @@ +package org.apache.maven.surefire.junitplatform; + +/* + * 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. + */ + +import static org.apache.maven.surefire.report.SimpleReportEntry.ignored; +import static org.junit.platform.engine.TestExecutionResult.Status.ABORTED; +import static org.junit.platform.engine.TestExecutionResult.Status.FAILED; + +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.maven.surefire.report.PojoStackTraceWriter; +import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.SimpleReportEntry; +import org.apache.maven.surefire.report.StackTraceWriter; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.engine.TestSource; +import org.junit.platform.engine.support.descriptor.ClassSource; +import org.junit.platform.engine.support.descriptor.MethodSource; +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestIdentifier; +import org.junit.platform.launcher.TestPlan; +import org.junit.platform.launcher.listeners.LegacyReportingUtils; + +/** + * @since 2.22.0 + */ +final class RunListenerAdapter +implements TestExecutionListener +{ + +private final RunListener runListener; + +private TestPlan testPlan; + +private Set testSetNodes = ConcurrentHashMap.newKeySet(); + +RunListenerAdapter( RunListener runListener ) +{ +this.runListener = runListener; +} + +@Override +public void testPlanExecutionStarted( TestPlan testPlan ) +{ +updateTestPlan( testPlan ); +} + +@Override +public void testPlanExecutionFinished( TestPlan testPlan ) +{ +updateTestPlan( null ); +} + +@Override +public void executionStarted( TestIdentifier testIdentifier ) +{ +if ( testIdentifier.isContainer() +&& testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent() ) +{ +startTestSetIfPossible( testIdentifier ); +} +if ( testIdentifier.isTest() ) +{ +ensureTestSetStarted( testIdentifier ); +runListener.testStarting( createReportEntry( testIdentifier ) ); +} +} + +@Override +public void executionSkipped( TestIdentifier testIdentifier, String reason ) +{ +ensureTestSetStarted( testIdentifier ); +String source = getLegacyReportingClassName( testIdentifier ); +runListener.testSkipped( ignored( source, getLegacyReportingName( testIdentifier ), reason ) ); +completeTestSetIfNecessary( testIdentifier ); +} + +@Override +public void executionFinished( +TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ) +{ +if ( testExecutionResult.getStatus() == ABORTED ) +{ +runListener.testAssumptionFailure( createReportEntry( testIdentifier, testExecutionResult ) ); +} +else if ( testExecutionResult.getStatus() == FAILED ) +{ +reportFailedTest( testIdentifier, testExecutionResult ); +} +else if ( testIdentifier.isTest() ) +{ +runListener.testSucceeded( createReportEntry( testIdentifier ) ); +} +completeTestSetIfNecessary( testIdentifier ); +} + +private void updateTestPlan( TestPlan testPlan ) +{ +this.testPlan = testPlan; +testSetNodes.clear(); +} + +private void ensureTestSetStarted( TestIdentifier testIdentifier ) +{ +if ( isTestSetStarted( testIdentifier ) ) +{ +return; +} +if ( testIdentifier.isTest() ) +{ +startTestSet( testPlan.getParent( testIdentifier ).orElse( testIdentifier ) ); +} +
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r192987675 ## File path: surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java ## @@ -0,0 +1,272 @@ +package org.apache.maven.surefire.junitplatform; + +/* + * 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. + */ + +import static org.apache.maven.surefire.report.SimpleReportEntry.ignored; +import static org.junit.platform.engine.TestExecutionResult.Status.ABORTED; +import static org.junit.platform.engine.TestExecutionResult.Status.FAILED; + +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.maven.surefire.report.PojoStackTraceWriter; +import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.SimpleReportEntry; +import org.apache.maven.surefire.report.StackTraceWriter; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.engine.TestSource; +import org.junit.platform.engine.support.descriptor.ClassSource; +import org.junit.platform.engine.support.descriptor.MethodSource; +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestIdentifier; +import org.junit.platform.launcher.TestPlan; +import org.junit.platform.launcher.listeners.LegacyReportingUtils; + +/** + * @since 2.22.0 + */ +final class RunListenerAdapter +implements TestExecutionListener +{ + +private final RunListener runListener; + +private TestPlan testPlan; + +private Set testSetNodes = ConcurrentHashMap.newKeySet(); + +RunListenerAdapter( RunListener runListener ) +{ +this.runListener = runListener; +} + +@Override +public void testPlanExecutionStarted( TestPlan testPlan ) +{ +updateTestPlan( testPlan ); +} + +@Override +public void testPlanExecutionFinished( TestPlan testPlan ) +{ +updateTestPlan( null ); +} + +@Override +public void executionStarted( TestIdentifier testIdentifier ) +{ +if ( testIdentifier.isContainer() +&& testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent() ) +{ +startTestSetIfPossible( testIdentifier ); +} +if ( testIdentifier.isTest() ) +{ +ensureTestSetStarted( testIdentifier ); +runListener.testStarting( createReportEntry( testIdentifier ) ); +} +} + +@Override +public void executionSkipped( TestIdentifier testIdentifier, String reason ) +{ +ensureTestSetStarted( testIdentifier ); +String source = getLegacyReportingClassName( testIdentifier ); +runListener.testSkipped( ignored( source, getLegacyReportingName( testIdentifier ), reason ) ); +completeTestSetIfNecessary( testIdentifier ); +} + +@Override +public void executionFinished( +TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ) +{ +if ( testExecutionResult.getStatus() == ABORTED ) +{ +runListener.testAssumptionFailure( createReportEntry( testIdentifier, testExecutionResult ) ); +} +else if ( testExecutionResult.getStatus() == FAILED ) +{ +reportFailedTest( testIdentifier, testExecutionResult ); +} +else if ( testIdentifier.isTest() ) +{ +runListener.testSucceeded( createReportEntry( testIdentifier ) ); +} +completeTestSetIfNecessary( testIdentifier ); +} + +private void updateTestPlan( TestPlan testPlan ) +{ +this.testPlan = testPlan; +testSetNodes.clear(); +} + +private void ensureTestSetStarted( TestIdentifier testIdentifier ) +{ +if ( isTestSetStarted( testIdentifier ) ) +{ +return; +} +if ( testIdentifier.isTest() ) +{ +startTestSet( testPlan.getParent( testIdentifier ).orElse( testIdentifier ) ); +} +
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191527237 ## File path: maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm ## @@ -0,0 +1,206 @@ + -- + Using JUnit Platform + -- + JUnit Lambda Team + -- + 2018-05-14 + -- + + ~~ 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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +Using JUnit Platform + +* Configuring JUnit Platform + + To get started with JUnit Platform, you need to add at least a single <<>> implementation + to your project. For example, if you want to write tests with Jupiter, you must add the + <<>> to the dependencies like: + ++---+ + + [...] + + org.junit.jupiter + junit-jupiter-engine + 5.2.0 + test + + [...] + ++---+ + + This will pull in all required dependencies. Among those dependencies is <<>> which contains + the classes and interfaces your test source requires to compile. <<>> is also resolved and + added. + + This is the only step that is required to get started - you can now create tests in your test source directory + (e.g., <<>>). + + If you want to write and execute JUnit 3 or 4 tests via the JUnit Platform add the Vintage Engine to your projects' + dependencies: + ++---+ + + [...] + + org.junit.vintage + junit-vintage-engine + 5.2.0 + test + + [...] + ++---+ + +* Provider Selection + + If nothing is configured, Surefire detects which JUnit version to use by the following algorithm: + ++---+ +if the JUnit Platform Engine is present in the project +use junit-platform +if the JUnit version in the project >= 4.7 and the parallel attribute has ANY value +use junit47 provider +if JUnit >= 4.0 is present +use junit4 provider +else +use junit3.8.1 ++---+ + + When using this technique there is no check that the proper test-frameworks are present on your project's + classpath. Failing to add the proper test-frameworks will result in a build failure. + +* Running Tests in Parallel + + From JUnit Platform does not support running tests in parallel. + +* Running a Single Test Class + + The JUnit Platform Provider supports the <<>> JVM system property supported by + the Maven Surefire Plugin. For example, to run only test methods in the <<>> test class + you can execute <<>> from the command line. + + +* Filtering by Test Class Names + + The Maven Surefire Plugin will scan for test classes whose fully qualified names match + the following patterns. + + * <<<**/Test*.java>>> + + * <<<**/*Test.java>>> + + * <<<**/*Tests.java>>> + + * <<<**/*TestCase.java>>> + +Moreover, it will exclude all nested classes (including static member classes) by default. + +Note, however, that you can override this default behavior by configuring explicit +`include` and `exclude` rules in your `pom.xml` file. For example, to keep Maven Surefire +from excluding static member classes, you can override its exclude rules. + +Overriding exclude rules of Maven Surefire + ++---+ +... + + +... + +maven-surefire-plugin +{surefire-version} + + + + + +... + + + +... ++---+ + + +* Filtering by Tags + +You can filter tests by tags or tag expressions using the following configuration properties. + +* to include <<>> or <<>>, use either <<>> or <<>>. + +* to exclude <<>> or <<>>, use either <<>> or <<>>. + ++---+ +... + + +... + +maven-surefire-plugin +{surefire-version} + + +acceptance | !feature-a Review comment: The tags (include and exclude) are passed as filters to the `org.apache.maven.surefire.junitplatform.TestPlanScannerFilter` in line: https://github.com/apache/maven-surefire/pull/184/files#diff-b3a2904e92be87f11f2622fbfd122e31R137 The filters are generated
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191075060 ## File path: maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm ## @@ -0,0 +1,206 @@ + -- + Using JUnit Platform + -- + JUnit Lambda Team+ -- + 2018-05-14 + -- + + ~~ 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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +Using JUnit Platform + +* Configuring JUnit Platform + + To get started with JUnit Platform, you need to add at least a single <<>> implementation + to your project. For example, if you want to write tests with Jupiter, you must add the + <<>> to the dependencies like: + ++---+ + + [...] + + org.junit.jupiter + junit-jupiter-engine + 5.2.0 + test + + [...] + ++---+ + + This will pull in all required dependencies. Among those dependencies is <<>> which contains + the classes and interfaces your test source requires to compile. <<>> is also resolved and + added. + + This is the only step that is required to get started - you can now create tests in your test source directory + (e.g., <<>>). + + If you want to write and execute JUnit 3 or 4 tests via the JUnit Platform add the Vintage Engine to your projects' + dependencies: + ++---+ + + [...] + + org.junit.vintage + junit-vintage-engine + 5.2.0 + test + + [...] + ++---+ + +* Provider Selection + + If nothing is configured, Surefire detects which JUnit version to use by the following algorithm: + ++---+ +if the JUnit Platform Engine is present in the project +use junit-platform +if the JUnit version in the project >= 4.7 and the parallel attribute has ANY value +use junit47 provider +if JUnit >= 4.0 is present +use junit4 provider +else +use junit3.8.1 ++---+ + + When using this technique there is no check that the proper test-frameworks are present on your project's + classpath. Failing to add the proper test-frameworks will result in a build failure. + +* Running Tests in Parallel + + From JUnit Platform does not support running tests in parallel. + +* Running a Single Test Class + + The JUnit Platform Provider supports the <<>> JVM system property supported by + the Maven Surefire Plugin. For example, to run only test methods in the <<>> test class + you can execute <<>> from the command line. + + +* Filtering by Test Class Names + + The Maven Surefire Plugin will scan for test classes whose fully qualified names match + the following patterns. + + * <<<**/Test*.java>>> + + * <<<**/*Test.java>>> + + * <<<**/*Tests.java>>> + + * <<<**/*TestCase.java>>> + +Moreover, it will exclude all nested classes (including static member classes) by default. + +Note, however, that you can override this default behavior by configuring explicit +`include` and `exclude` rules in your `pom.xml` file. For example, to keep Maven Surefire +from excluding static member classes, you can override its exclude rules. + +Overriding exclude rules of Maven Surefire + ++---+ +... + + +... + +maven-surefire-plugin +{surefire-version} + + + + + +... + + + +... ++---+ + + +* Filtering by Tags + +You can filter tests by tags or tag expressions using the following configuration properties. + +* to include <<>> or <<>>, use either <<>> or <<>>. + +* to exclude <<>> or <<>>, use either <<>> or <<>>. + ++---+ +... + + +... + +maven-surefire-plugin +{surefire-version} + + +acceptance | !feature-a +integration, regression + + + +... + + + + +... ++---+ + + +* Configuration Parameters + + You can set JUnit Platform configuration parameters to influence
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191074742 ## File path: maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm ## @@ -0,0 +1,206 @@ + -- + Using JUnit Platform + -- + JUnit Lambda Team+ -- + 2018-05-14 + -- + + ~~ 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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +Using JUnit Platform + +* Configuring JUnit Platform + + To get started with JUnit Platform, you need to add at least a single <<>> implementation + to your project. For example, if you want to write tests with Jupiter, you must add the + <<>> to the dependencies like: + ++---+ + + [...] + + org.junit.jupiter + junit-jupiter-engine + 5.2.0 + test + + [...] + ++---+ + + This will pull in all required dependencies. Among those dependencies is <<>> which contains + the classes and interfaces your test source requires to compile. <<>> is also resolved and + added. + + This is the only step that is required to get started - you can now create tests in your test source directory + (e.g., <<>>). + + If you want to write and execute JUnit 3 or 4 tests via the JUnit Platform add the Vintage Engine to your projects' + dependencies: + ++---+ + + [...] + + org.junit.vintage + junit-vintage-engine + 5.2.0 + test + + [...] + ++---+ + +* Provider Selection + + If nothing is configured, Surefire detects which JUnit version to use by the following algorithm: + ++---+ +if the JUnit Platform Engine is present in the project +use junit-platform +if the JUnit version in the project >= 4.7 and the parallel attribute has ANY value +use junit47 provider +if JUnit >= 4.0 is present +use junit4 provider +else +use junit3.8.1 ++---+ + + When using this technique there is no check that the proper test-frameworks are present on your project's + classpath. Failing to add the proper test-frameworks will result in a build failure. + +* Running Tests in Parallel + + From JUnit Platform does not support running tests in parallel. + +* Running a Single Test Class + + The JUnit Platform Provider supports the <<>> JVM system property supported by + the Maven Surefire Plugin. For example, to run only test methods in the <<>> test class + you can execute <<>> from the command line. + + +* Filtering by Test Class Names + + The Maven Surefire Plugin will scan for test classes whose fully qualified names match + the following patterns. + + * <<<**/Test*.java>>> + + * <<<**/*Test.java>>> + + * <<<**/*Tests.java>>> + + * <<<**/*TestCase.java>>> + +Moreover, it will exclude all nested classes (including static member classes) by default. + +Note, however, that you can override this default behavior by configuring explicit +`include` and `exclude` rules in your `pom.xml` file. For example, to keep Maven Surefire +from excluding static member classes, you can override its exclude rules. + +Overriding exclude rules of Maven Surefire + ++---+ +... + + +... + +maven-surefire-plugin +{surefire-version} + + + + + +... + + + +... ++---+ + + +* Filtering by Tags + +You can filter tests by tags or tag expressions using the following configuration properties. + +* to include <<>> or <<>>, use either <<>> or <<>>. + +* to exclude <<>> or <<>>, use either <<>> or <<>>. + ++---+ +... + + +... + +maven-surefire-plugin +{surefire-version} + + +acceptance | !feature-a Review comment: Do you mean with > Surefire's parameters `groups` and `excludedGroups` the TestNG specific contants in `org.apache.maven.surefire.booter.ProviderParameterNames`? ```java public static final String
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191073686 ## File path: maven-surefire-plugin/src/site/apt/featurematrix.apt.vm ## @@ -27,19 +27,19 @@ Feature Matrix Not all features are supported for all test frameworks, and the following table gives a brief overview of support status: -*-+---+---++---+--+ -|| <> ||<>||<>||<>||<>||<> | -*-++--++---+--+ -| groups/category support | N |N | Y |Y | N | -*-++--++---+--+ -| security manager support| Y |N | N |N | N | -*-++--++---+--+ -| runOrder support| Y |Y | Y |? | Y | -*-++--++---+--+ -| run >1 individual test method in a class| N |Y | Y |Y | N | -*-++--++---+--+ -| parallel support| N |N | Y |Y | N | -*-++--++---+--+ +*-+---+---++---+--++ +|| <> ||<>||<>||<>||<>||<> ||<> | +*-++--++---+--++ +| groups/category/tags support| N |N | Y |Y | N | Y | +*-++--++---+--++ +| security manager support| Y |N | N |N | N | N | +*-++--++---+--++ +| runOrder support| Y |Y | Y |? | Y | N | +*-++--++---+--++ +| run >1 individual test method in a class| N |Y | Y |Y | N | ? | Review comment: Keeping the `?` and adding the links as footnotes to the matrix. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191073633 ## File path: maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm ## @@ -0,0 +1,206 @@ + -- + Using JUnit Platform + -- + JUnit Lambda Team+ -- + 2018-05-14 + -- + + ~~ 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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +Using JUnit Platform + +* Configuring JUnit Platform + + To get started with JUnit Platform, you need to add at least a single <<>> implementation + to your project. For example, if you want to write tests with Jupiter, you must add the + <<>> to the dependencies like: + ++---+ + + [...] + + org.junit.jupiter + junit-jupiter-engine + 5.2.0 + test + + [...] + ++---+ + + This will pull in all required dependencies. Among those dependencies is <<>> which contains + the classes and interfaces your test source requires to compile. <<>> is also resolved and + added. + + This is the only step that is required to get started - you can now create tests in your test source directory + (e.g., <<>>). + + If you want to write and execute JUnit 3 or 4 tests via the JUnit Platform add the Vintage Engine to your projects' + dependencies: + ++---+ + + [...] + + org.junit.vintage + junit-vintage-engine + 5.2.0 + test + + [...] + ++---+ + +* Provider Selection + + If nothing is configured, Surefire detects which JUnit version to use by the following algorithm: + ++---+ +if the JUnit Platform Engine is present in the project +use junit-platform +if the JUnit version in the project >= 4.7 and the parallel attribute has ANY value Review comment: Sure. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191073608 ## File path: maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm ## @@ -0,0 +1,206 @@ + -- + Using JUnit Platform + -- + JUnit Lambda Team+ -- + 2018-05-14 + -- + + ~~ 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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +Using JUnit Platform + +* Configuring JUnit Platform + + To get started with JUnit Platform, you need to add at least a single <<>> implementation + to your project. For example, if you want to write tests with Jupiter, you must add the + <<>> to the dependencies like: + ++---+ + + [...] + + org.junit.jupiter + junit-jupiter-engine + 5.2.0 + test + + [...] + ++---+ + + This will pull in all required dependencies. Among those dependencies is <<>> which contains + the classes and interfaces your test source requires to compile. <<>> is also resolved and + added. + + This is the only step that is required to get started - you can now create tests in your test source directory + (e.g., <<>>). + + If you want to write and execute JUnit 3 or 4 tests via the JUnit Platform add the Vintage Engine to your projects' + dependencies: + ++---+ + + [...] + + org.junit.vintage + junit-vintage-engine + 5.2.0 + test + + [...] + ++---+ + +* Provider Selection + + If nothing is configured, Surefire detects which JUnit version to use by the following algorithm: + ++---+ +if the JUnit Platform Engine is present in the project +use junit-platform +if the JUnit version in the project >= 4.7 and the parallel attribute has ANY value +use junit47 provider +if JUnit >= 4.0 is present +use junit4 provider +else +use junit3.8.1 ++---+ + + When using this technique there is no check that the proper test-frameworks are present on your project's + classpath. Failing to add the proper test-frameworks will result in a build failure. + +* Running Tests in Parallel + + From JUnit Platform does not support running tests in parallel. + +* Running a Single Test Class + + The JUnit Platform Provider supports the <<>> JVM system property supported by + the Maven Surefire Plugin. For example, to run only test methods in the <<>> test class + you can execute <<>> from the command line. + + +* Filtering by Test Class Names + + The Maven Surefire Plugin will scan for test classes whose fully qualified names match + the following patterns. + + * <<<**/Test*.java>>> + + * <<<**/*Test.java>>> + + * <<<**/*Tests.java>>> + + * <<<**/*TestCase.java>>> + +Moreover, it will exclude all nested classes (including static member classes) by default. + +Note, however, that you can override this default behavior by configuring explicit +`include` and `exclude` rules in your `pom.xml` file. For example, to keep Maven Surefire +from excluding static member classes, you can override its exclude rules. + +Overriding exclude rules of Maven Surefire + ++---+ +... + + +... + +maven-surefire-plugin +{surefire-version} + + + + + +... + + + +... ++---+ + + +* Filtering by Tags + +You can filter tests by tags or tag expressions using the following configuration properties. + +* to include <<>> or <<>>, use either <<>> or <<>>. + +* to exclude <<>> or <<>>, use either <<>> or <<>>. + ++---+ +... + + +... + +maven-surefire-plugin +{surefire-version} + + +acceptance | !feature-a Review comment: I'll take a look. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191073570 ## File path: maven-surefire-plugin/src/site/site.xml ## @@ -40,6 +40,7 @@ + Review comment: Sure. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191073566 ## File path: maven-surefire-plugin/src/site/apt/index.apt.vm ## @@ -141,6 +141,8 @@ mvn verify * {{{./examples/testng.html}Using TestNG}} + * {{{./examples/junit-platform.html}Using JUnit Platform}} Review comment: Sure. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r191073560 ## File path: maven-surefire-plugin/src/site/apt/featurematrix.apt.vm ## @@ -27,19 +27,19 @@ Feature Matrix Not all features are supported for all test frameworks, and the following table gives a brief overview of support status: -*-+---+---++---+--+ -|| <> ||<>||<>||<>||<>||<> | -*-++--++---+--+ -| groups/category support | N |N | Y |Y | N | -*-++--++---+--+ -| security manager support| Y |N | N |N | N | -*-++--++---+--+ -| runOrder support| Y |Y | Y |? | Y | -*-++--++---+--+ -| run >1 individual test method in a class| N |Y | Y |Y | N | -*-++--++---+--+ -| parallel support| N |N | Y |Y | N | -*-++--++---+--+ +*-+---+---++---+--++ +|| <> ||<>||<>||<>||<>||<> ||<> | +*-++--++---+--++ +| groups/category/tags support| N |N | Y |Y | N | Y | +*-++--++---+--++ +| security manager support| Y |N | N |N | N | N | +*-++--++---+--++ +| runOrder support| Y |Y | Y |? | Y | N | +*-++--++---+--++ +| run >1 individual test method in a class| N |Y | Y |Y | N | ? | +*-++--++---+--++ +| parallel support| N |N | Y |Y | N | N | Review comment: We should stick with 'N' for now. Let's see which way is best to implement parallel execution support for the Platform. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r186260157 ## File path: surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java ## @@ -58,6 +58,11 @@ import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; import org.junit.platform.launcher.core.LauncherFactory; +/** + * JUnitPlatformProvider. + * + * @since 1.0 Review comment: Fixing all JUnit-related versions to `2.22.0`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r186260157 ## File path: surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java ## @@ -58,6 +58,11 @@ import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; import org.junit.platform.launcher.core.LauncherFactory; +/** + * JUnitPlatformProvider. + * + * @since 1.0 Review comment: Fixing all JUnit-related version to `2.22.0`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider
sormuras commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider URL: https://github.com/apache/maven-surefire/pull/184#discussion_r186260085 ## File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java ## @@ -1022,9 +1029,9 @@ private void createDependencyResolver() Artifact junitDepArtifact = getJunitDepArtifact(); return new ProviderList( new DynamicProviderInfo( null ), new TestNgProviderInfo( getTestNgArtifact() ), + new JUnitPlatformProviderInfo( getJunitPlatformArtifact() ), Review comment: Are the built-in providers documented somewhere? I couldn't find any external information. The first auto-detected provider wins, right? If I understand the `isApplicable()` logic correctly, the `platform` info needs to checked before the legacy JUnit (3 + 4) infos. This is due to fact, that a legacy "junit-4.12.jar" is present in both cases: the users is on 4 and wants to run JUnit 4 test cases. Or the user is on "5" and wants to Vintage Engine to execute JUnit 4 or 3 test cases. So, when we find `org.junit.platform:junit-platform-engine` as a dependency the uses wants to launch the JUnit Platform -- perhaps with the Vintage Engine which brings along JUnit 4.x jar. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services