Skip to content

Commit 61b1e98

Browse files
committed
Document Maven Surefire test filtering support in User Guide
Closes: #1245
1 parent 63550fc commit 61b1e98

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

documentation/src/docs/asciidoc/running-tests.adoc

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ currently only works with Surefire 2.19.1.
376376
...
377377
<plugin>
378378
<artifactId>maven-surefire-plugin</artifactId>
379-
<version>2.19</version>
379+
<version>2.19.1</version>
380380
<dependencies>
381381
<dependency>
382382
<groupId>org.junit.platform</groupId>
@@ -409,7 +409,7 @@ dependencies of the `maven-surefire-plugin` similar to the following.
409409
...
410410
<plugin>
411411
<artifactId>maven-surefire-plugin</artifactId>
412-
<version>2.19</version>
412+
<version>2.19.1</version>
413413
<dependencies>
414414
<dependency>
415415
<groupId>org.junit.platform</groupId>
@@ -451,7 +451,7 @@ the dependencies of the `maven-surefire-plugin` similar to the following.
451451
...
452452
<plugin>
453453
<artifactId>maven-surefire-plugin</artifactId>
454-
<version>2.19</version>
454+
<version>2.19.1</version>
455455
<dependencies>
456456
<dependency>
457457
<groupId>org.junit.platform</groupId>
@@ -481,13 +481,38 @@ the dependencies of the `maven-surefire-plugin` similar to the following.
481481
...
482482
----
483483

484+
[[running-tests-build-maven-test-system-property]]
485+
===== Running a Single Test Class
486+
487+
The JUnit Platform Surefire Provider supports the `test` JVM system property supported by
488+
the Maven Surefire Plugin. For example, to run only test methods in the
489+
`org.example.MyTest` test class you can execute `mvn -Dtest=org.example.MyTest test` from
490+
the command line. For further details, consult the
491+
https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html[Maven Surefire Plugin]
492+
documentation.
493+
494+
[[running-tests-build-maven-filter-test-class-names]]
495+
===== Filtering by Test Class Names
496+
497+
The Maven Surefire Plugin will scan for test classes whose fully qualified names match
498+
the following patterns.
499+
500+
- `+**/Test*.java+`
501+
- `+**/*Test.java+`
502+
- `+**/*TestCase.java+`
503+
504+
Note, however, that you can override this default behavior by configuring explicit
505+
`include` and `exclude` rules in your `pom.xml` file. See the
506+
https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html[Inclusions and Exclusions of Tests]
507+
documentation for Maven Surefire for details.
508+
484509
[[running-tests-build-maven-filter-tags]]
485510
===== Filtering by Tags
486511

487512
You can filter tests by tags using the following configuration properties.
488513

489-
- to include a tag, use either `groups` or `includeTags`
490-
- to exclude a tag, use either `excludedGroups` or `excludeTags`
514+
- To include a tag, use either `groups` or `includeTags`.
515+
- To exclude a tag, use either `excludedGroups` or `excludeTags`.
491516

492517
[source,xml,indent=0]
493518
----
@@ -497,7 +522,7 @@ You can filter tests by tags using the following configuration properties.
497522
...
498523
<plugin>
499524
<artifactId>maven-surefire-plugin</artifactId>
500-
<version>2.19</version>
525+
<version>2.19.1</version>
501526
<configuration>
502527
<properties>
503528
<includeTags>acceptance</includeTags>
@@ -528,7 +553,7 @@ the `configurationParameters` property and providing key-value pairs in the Java
528553
...
529554
<plugin>
530555
<artifactId>maven-surefire-plugin</artifactId>
531-
<version>2.19</version>
556+
<version>2.19.1</version>
532557
<configuration>
533558
<properties>
534559
<configurationParameters>

0 commit comments

Comments
 (0)