-DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下 -Dmaven.test.skip=true,不执行测试用例,也不编译测试用例类
mvn package -Dmaven.test.skip=true 跳过单元测试的运行,也跳过测试代码的编译
<plugin>
<groupId>org.apache.maven.plugin</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
mvn package -DskipTests 跳过单元测试,但是会继续编译
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
- idea默认的跳过测试采用的是第二种,所以仍然会编译代码
|