@@ -208,12 +208,13 @@ additional dependency to the runtime classpath.
208208[[running-tests-build-maven]]
209209==== Maven
210210
211- The JUnit team has developed a very basic provider for Maven Surefire that lets you run
212- JUnit 4 and JUnit Jupiter tests via `mvn test`. The `pom.xml` file in the
211+ The JUnit team has developed a basic provider for Maven Surefire that lets you run JUnit 4
212+ and JUnit Jupiter tests via `mvn test`. The `pom.xml` file in the
213213`{junit5-maven-consumer}` project demonstrates how to use it and can serve as a starting
214214point.
215215
216- NOTE: Please use Maven Surefire 2.21.0 with the `junit-platform-surefire-provider`.
216+ NOTE: Please use Maven Surefire {surefire-version} with the
217+ `junit-platform-surefire-provider`.
217218
218219[source,xml,indent=0]
219220[subs=attributes+]
@@ -224,7 +225,7 @@ NOTE: Please use Maven Surefire 2.21.0 with the `junit-platform-surefire-provide
224225 ...
225226 <plugin>
226227 <artifactId>maven-surefire-plugin</artifactId>
227- <version>2.21.0 </version>
228+ <version>{surefire-version} </version>
228229 <dependencies>
229230 <dependency>
230231 <groupId>org.junit.platform</groupId>
@@ -257,7 +258,7 @@ dependencies of the `maven-surefire-plugin` similar to the following.
257258 ...
258259 <plugin>
259260 <artifactId>maven-surefire-plugin</artifactId>
260- <version>2.21.0 </version>
261+ <version>{surefire-version} </version>
261262 <dependencies>
262263 <dependency>
263264 <groupId>org.junit.platform</groupId>
@@ -299,7 +300,7 @@ the dependencies of the `maven-surefire-plugin` similar to the following.
299300 ...
300301 <plugin>
301302 <artifactId>maven-surefire-plugin</artifactId>
302- <version>2.21.0 </version>
303+ <version>{surefire-version} </version>
303304 <dependencies>
304305 <dependency>
305306 <groupId>org.junit.platform</groupId>
@@ -347,11 +348,39 @@ the following patterns.
347348
348349- `+**/Test*.java+`
349350- `+**/*Test.java+`
350- - `+**/*Tests.java+` _(supported since Surefire 2.20)_
351+ - `+**/*Tests.java+`
351352- `+**/*TestCase.java+`
352353
354+ Moreover, it will exclude all nested classes (including static member classes) by default.
355+
353356Note, however, that you can override this default behavior by configuring explicit
354- `include` and `exclude` rules in your `pom.xml` file. See the
357+ `include` and `exclude` rules in your `pom.xml` file. For example, to keep Maven Surefire
358+ from excluding static member classes, you can override its exclude rules.
359+
360+ [source,xml,indent=0]
361+ [subs=attributes+]
362+ .Overriding exclude rules of Maven Surefire
363+ ----
364+ ...
365+ <build>
366+ <plugins>
367+ ...
368+ <plugin>
369+ <artifactId>maven-surefire-plugin</artifactId>
370+ <version>{surefire-version}</version>
371+ <configuration>
372+ <excludes>
373+ <exclude/>
374+ </excludes>
375+ </configuration>
376+ ...
377+ </plugin>
378+ </plugins>
379+ </build>
380+ ...
381+ ----
382+
383+ Please see the
355384https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html[Inclusions and Exclusions of Tests]
356385documentation for Maven Surefire for details.
357386
@@ -365,14 +394,15 @@ the following configuration properties.
365394- to exclude _tags_ or _tag expressions_, use either `excludedGroups` or `excludeTags`.
366395
367396[source,xml,indent=0]
397+ [subs=attributes+]
368398----
369399 ...
370400 <build>
371401 <plugins>
372402 ...
373403 <plugin>
374404 <artifactId>maven-surefire-plugin</artifactId>
375- <version>2.21.0 </version>
405+ <version>{surefire-version} </version>
376406 <configuration>
377407 <properties>
378408 <includeTags>acceptance | !feature-a</includeTags>
@@ -397,14 +427,15 @@ property and providing key-value pairs using the Java `Properties` file syntax (
397427below) or via the `junit-platform.properties` file.
398428
399429[source,xml,indent=0]
430+ [subs=attributes+]
400431----
401432 ...
402433 <build>
403434 <plugins>
404435 ...
405436 <plugin>
406437 <artifactId>maven-surefire-plugin</artifactId>
407- <version>2.21.0 </version>
438+ <version>{surefire-version} </version>
408439 <configuration>
409440 <properties>
410441 <configurationParameters>
0 commit comments