Make maven’s surefire show stacktrace in console

A related problem that I found is that surefire in recent versions apparently sets trimStackTrace to true by default (rendering most stack trace in failed tests useless), which is quite inconvenient. Setting -DtrimStackTrace=false or defining <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <trimStackTrace>false</trimStackTrace> </configuration> </plugin> solved this.

Generate test-jar along with jar file in test package

By using the following configuration you can create a jar from your tests: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> To use such kind of artifact: <dependencies> <dependency> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> <type>test-jar</type> <version>version</version> <classifier>tests</classifier> <scope>test</scope> </dependency> </dependencies>

Strategy for debugging surefire “The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?”

Steps: (1) Run mvn with the -e and -X options to get more debug information. (2) Look for “Error” in the output. In my case, when I ran the mvn command, part of the output included: [ERROR] Command wascmd.exe /X /C “C:\dev\dev-tools\….. (3) Execute the problematic command directly in the command shell. In my case, … Read more

Cannot use jacoco JVM args and surefire JVM args together in maven

Try using @{argLine} instead of ${argLine} (or surefire.argLine in your case) It allows surefire to read a property as modified by other plugins instead of reading the one substituted by Maven itself. Then you can set the argLine param to empty in Maven properties: <properties> <argLine></argLine> </properties> Which now will not cause any problems. More … Read more

How can I skip tests in maven install goal, while running them in maven test goal?

It sounds like you didn’t understand the concept of the build life-cycle in Maven. If you run mvn install all life-cycle phases (including the install phase itself) run before the install phase. This means running the following phases: validate initialize generate-sources process-sources generate-resources process-resources compile process-classes generate-test-sources process-test-sources generate-test-resources process-test-resources test-compile process-test-classes test prepare-package package … Read more

Prevent unit tests but allow integration tests in Maven

I found the simplest way to skip only surefire tests is to configure surefire (but not failsafe) as follows: <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.14</version> <configuration> <!– skips surefire tests without skipping failsafe tests. Property value seems to magically default to false –> <skipTests>${skip.surefire.tests}</skipTests> </configuration> </plugin> This allows you to run mvn verify -Dskip.surefire.tests and only surefire, not … Read more

The forked VM terminated without saying properly goodbye. VM crash or System.exit called

I had the same problem and solved by adding: <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> The whole plugin element is: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkCount>3</forkCount> <reuseForks>true</reuseForks> <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> </configuration> </plugin>