How to install in pom so as not to compile tests?

How to install in pom so as not to compile tests in Maven? I tried:

<properties> <skipTests>true</skipTests> </properties> 

but in this case, Maven will compile the tests, but will not run them. I need Maven not to compile my tests.

+6
source share
4 answers

In my case, the solution was to put the tests in the profile (e.g. runTests), so when I want to run these tests, I add the -PrunTests parameter. Thanks for answers.

0
source

You must define maven.test.skip for true.

 <properties> <maven.test.skip>true</maven.test.skip> </properties> 

http://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html

+5
source

If you use the surefire-plugin to run tests, you can configure it to skip them based on the naming pattern:

 <project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.14</version> <configuration> <includes> <include>%regex[.*[Cat|Dog].*Test.*]</include> </includes> </configuration> </plugin> </plugins> </build> [...] </project> 

This, however, requires that the test file names match the required patterns. At work, we use this approach, and our tests end with ..UnitTest or ..IntegrationTest , so that we can easily disable each of them by changing the regular expression in the corresponding build profile.

Check out the Apache documentation for the surefire plugin. You may find something more useful or more suitable for your business.

0
source

Configure maven-compiler-plugin to skip compilation. Once again, I do not recommend it.

 <project> <properties> <maven.test.skip>true</maven.test.skip> </properties> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <executions> <execution> <id>default-testCompile</id> <phase>test-compile</phase> <goals> <goal>testCompile</goal> </goals> <configuration> <skip>${maven.test.skip}</skip> </configuration> </execution> </executions> </plugin> </plugins> </build> [...] </project> 
0
source

All Articles