### Build surefire-shared-utils for IDE Source: https://github.com/apache/maven-surefire/blob/master/README.md Installs the shared utilities module into the local repository with the ide-development profile enabled. ```bash mvn install -P ide-development -f surefire-shared-utils/pom.xml ``` -------------------------------- ### TestNG Dependency Example Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/whats-new-3-6-0.md Example of a TestNG dependency configuration. Ensure your TestNG version is 6.14.3 or later for compatibility with Surefire 3.6.0. ```xml org.testng testng 7.10.2 test ``` -------------------------------- ### JUnit 4 Dependency Example Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/whats-new-3-6-0.md Example of a JUnit 4 dependency configuration. Ensure your JUnit 4 dependency is version 4.12 or later for compatibility with Surefire 3.6.0. ```xml junit junit 4.13.2 test ``` -------------------------------- ### Transitional Legacy Provider Configuration Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/whats-new-3-6-0.md Example Maven Surefire plugin configuration for Surefire 3.6.0, using a legacy provider from the 3.5.x line as a transitional measure. ```xml org.apache.maven.plugins maven-surefire-plugin 3.6.0 org.apache.maven.surefire surefire-junit4 3.5.5 ``` -------------------------------- ### Set JAVA_HOME for Java 9 Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/java9.md Set the JAVA_HOME environment variable to point to your JDK 9 installation before running Maven tests. ```bash export JAVA_HOME=/path/to/jdk9 mvn test ``` -------------------------------- ### Staying on Surefire 3.5.x Configuration Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/whats-new-3-6-0.md Example Maven Surefire plugin configuration to stay on version 3.5.x if test dependencies cannot be updated. ```xml org.apache.maven.plugins maven-surefire-plugin 3.5.5 ``` -------------------------------- ### Build and Test Project Source: https://github.com/apache/maven-surefire/blob/master/README.md Executes the build, site generation, and integration tests using the reporting and run-its profiles. ```bash mvn install site site:stage -P reporting,run-its ``` -------------------------------- ### Build and Test Commands for Maven Surefire Plugin Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md Common Maven commands for building the project, running unit and integration tests, and setting up IDE configurations. Ensure you meet the specified Maven and JDK version requirements. ```bash # Full build with unit tests mvn clean install ``` ```bash # Full build with integration tests mvn clean install -P run-its ``` ```bash # Build a single module mvn clean install -pl surefire-booter ``` ```bash # Run a single test mvn test -pl surefire-booter -Dtest=ForkedBooterTest ``` ```bash # Run a single integration test mvn verify -pl surefire-its -Prun-its -Dit.test=JUnit47RedirectOutputIT ``` ```bash # IDE setup (required before importing) mvn install -P ide-development -f surefire-shared-utils/pom.xml mvn compile -f surefire-grouper/pom.xml ``` -------------------------------- ### Run Maven Tests with Toolchains Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/java9.md Execute Maven tests using a specified toolchains.xml file by passing the path to the file using the '-t' command-line option. If '-t' is omitted, Maven defaults to searching for toolchains.xml in the user's .m2 directory. ```bash mvn -t /path/to/.m2/toolchains.xml test ``` -------------------------------- ### Use Legacy Provider as Plugin Dependency Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md As a transitional step, users can use a legacy provider as a plugin dependency, specifying both the Surefire plugin version and the legacy provider version. ```xml org.apache.maven.plugins maven-surefire-plugin 3.6.0 org.apache.maven.surefire surefire-junit3 3.5.4 ``` -------------------------------- ### Maven Surefire Plugin Forked JVM Architecture Sequence Diagram Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md Illustrates the flow of execution when tests are run in a forked JVM process, from the initial Maven command to test reporting. ```mermaid sequenceDiagram participant User as mvn test participant Mojo as AbstractSurefireMojo
(Maven JVM) participant FS as ForkStarter participant BS as BooterSerializer participant Fork as ForkedBooter.main()
(Forked JVM) participant Prov as SurefireProvider participant FC as ForkClient User->>Mojo: execute() Mojo->>Mojo: Auto-detect provider
(ProviderDetector) Mojo->>Mojo: Resolve provider classpath
(SurefireDependencyResolver) Mojo->>FS: fork() FS->>BS: Serialize config to .properties file FS->>FS: Build JVM command line
(ForkConfiguration) FS->>Fork: Launch process
(java -cp ... ForkedBooter) Fork->>Fork: setupBooter()
- Read .properties file
- Set system properties
- Connect communication channel
- Start PpidChecker (orphan detection) Fork->>Prov: Load provider via IsolatedClassLoader Fork->>Prov: invoke(testSet) Prov->>Prov: Run tests (JUnit/TestNG/etc.) loop For each test event Prov->>Fork: Report event via RunListener Fork-->>FC: Binary event stream
(EventChannelEncoder → pipe/TCP) FC-->>Mojo: Decoded Event objects
(EventDecoder → ForkedProcessEventNotifier) Mojo->>Mojo: Update console + write XML reports end Fork-->>FC: ControlByeEvent FC-->>FS: Run complete FS-->>Mojo: RunResult (pass/fail/skip counts) ``` -------------------------------- ### Maven Surefire Plugin Fork Configuration Variants Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md Lists the different implementations of ForkConfiguration used to build the forked JVM command line, based on classpath strategy. ```text ClasspathForkConfiguration -cp ``` ```text JarManifestForkConfiguration Creates a temp JAR with Class-Path manifest entry ``` ```text ModularClasspathForkConfiguration --module-path + --add-modules ``` -------------------------------- ### Configure MAVEN_OPTS for Release Checks Source: https://github.com/apache/maven-surefire/blob/master/README.md Sets memory and JVM parameters required for running tests during a release vote. ```bash export MAVEN_OPTS="-server -Xmx512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true" ``` ```batch set MAVEN_OPTS="-server -Xmx256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true" ``` -------------------------------- ### Configure Custom Stack Trace Filter Prefixes via Command Line Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md This command-line argument allows users to specify custom prefixes for filtering stack traces, replacing the default JDK package filters. This provides a flexible way to manage stack trace output during builds. ```bash mvn test -Dsurefire.stackTraceFilterPrefixes=org.springframework.,org.junit. ``` -------------------------------- ### Configure maven-toolchains-plugin in POM Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/java9.md Use this plugin configuration to specify a JDK version for the build process. Ensure the toolchain is defined in your local toolchains.xml file. ```xml org.apache.maven.plugins maven-toolchains-plugin 1.1 validate toolchain 9 ``` -------------------------------- ### Configure JVM path in Maven Surefire Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/java9.md Specify the exact path to the Java executable in JDK 9 using the 'jvm' configuration parameter within the Maven Surefire plugin. This method is generally unrecommended for portability. ```xml /path/to/jdk9/bin/java ``` -------------------------------- ### Configure Custom Stack Trace Filter Prefixes in XML Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md This XML configuration allows users to specify custom prefixes for filtering stack traces, replacing the default JDK package filters. This is useful for excluding specific application or library packages from stack traces. ```xml org.springframework. org.junit. ``` -------------------------------- ### Define JDK Toolchains in toolchains.xml Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/java9.md Define JDK toolchains in the toolchains.xml file to specify different JDK versions and their home directories. This allows Maven to select the appropriate JDK for the build. ```xml jdk 1.8 sun jdk8 /path/to/openjdk8 jdk 11 sun jdk11 /path/to/openjdk/11 ``` ```xml jdk 9 oracle jdk9 /path/to/jdk9 ``` -------------------------------- ### SurefireProvider SPI Interface Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md Defines the contract for test framework adapters implementing the SurefireProvider SPI. It includes methods for retrieving test suites, executing tests, and handling cancellation. ```java public interface SurefireProvider { // Returns test classes/suites — determines fork granularity Iterable> getSuites(); // Executes tests; forkTestSet is null for "run all" or a Class for per-test forking RunResult invoke(Object forkTestSet) throws TestSetFailedException, ReporterException; // Graceful cancellation on timeout void cancel(); } ``` -------------------------------- ### Pin Surefire to Version 3.5.x Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md If upgrading causes issues, users can pin the Surefire plugin to a previous version like 3.5.4. ```xml org.apache.maven.plugins maven-surefire-plugin 3.5.4 ``` -------------------------------- ### Configure JDK Toolchain in Maven Surefire Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/java9.md Configure the Maven Surefire plugin to use a specific JDK version (e.g., 11) and vendor (e.g., sun) by defining a JDK toolchain in the plugin's configuration. This assumes a corresponding entry exists in your toolchains.xml. ```xml [...] 11 sun [...] ``` -------------------------------- ### Maven Surefire Plugin Fork Modes Configuration Source: https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/markdown/architecture.md Defines the behavior for test execution regarding the number of forked JVMs and their reuse across test classes. ```xml 1 ``` ```xml 4 ``` ```xml 1C ``` ```xml true ``` ```xml false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.