Maven 提供了跳过单元测试的能力,只需要使用 Surefire 插件的 skip 参数。 在命令行,只要简单的给任何目标添加 maven.test.skip 属性就能跳过测试:

$ mvn install -Dmaven.test.skip=true
...
[INFO] [compiler:testCompile]
[INFO] Not compiling test sources
[INFO] [surefire:test]
[INFO] Tests are skipped.
...

当 Surefire 插件到达 test 目标的时候,如果 maven.test.skip 设置为 true ,它就会跳过单元测试。 另一种配置 Maven 跳过单元测试的方法是给你项目的 pom.xml 添加这个配置。 你需要为你的 build 添加 plugin 元素。

<project>
[...]
<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
</build>
[...]
</project>

当需要单元测试时,注意,一定要设置为false。

配置生产和测试环境两种:

<profiles>
<profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<filter.property.path>src/main/resources/properties/test.properties</filter.property.path>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<filter.property.path>src/main/resources/properties/production.properties</filter.property.path>
</properties>
</profile>
</profiles>

打包命令:

mvn package -Pproduction

maven中跳过单元测试的更多相关文章

  1. maven中跳过单元测试(转)

    你可能想要配置 Maven 使其完全跳过单元测试. 可能你有一个很大的系统,单元测试需要花好多分钟来完成,而你不想在生成最终输出前等单元测试完成. 你可能正工作在一个遗留系统上面,这个系统有一系列的失 ...

  2. maven跳过单元测试的两个参数区别

    maven在打包过程中需要执行单元测试.但有些时候单元测试已经通过只是想打包时,想跳过测试.maven提供了两个参数跳过测试:maven.test.skip=true 和skipTests. 例子 m ...

  3. 【转】maven跳过单元测试-maven.test.skip和skipTests的区别

    -DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下. -Dmaven.test.skip=true,不执行测试用例,也不编译测试 ...

  4. maven跳过单元测试-maven.test.skip和skipTests的区别

    1. 介绍 -DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下. -Dmaven.test.skip=true,不执行测试用例, ...

  5. maven跳过单元测试-maven.test.skip和skipTests的区别以及部分常用命令

    -DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下. -Dmaven.test.skip=true,不执行测试用例,也不编译测试 ...

  6. maven项目打包和编译跳过单元测试和javadoc

    代码中可能由于单元测试.注释(方法中的参数)或者maven javadoc插件的问题导致无法打包,影响工作,为避免这两种情况可以在打包时输入命令: mvn clean install -Dmaven. ...

  7. Maven跳过单元测试的两种方式

    -DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下. -Dmaven.test.skip=true,不执行测试用例,也不编译测试 ...

  8. maven跳过单元测试

    24.跳过单元测试 <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>mav ...

  9. Maven编译代码的时候跳过单元测试

    Maven编译代码的时候跳过单元测试 <properties> <maven.test.skip>true</maven.test.skip> </prope ...

随机推荐

  1. MyBatis动态SQL foreach标签实现批量插入

    需求:查出给定id的记录: <select id="getEmpsByConditionForeach" resultType="com.test.beans.Em ...

  2. git版本还原

    本地还原 在确认需要进行版本还原以后, 打开GIT BASH 输入: git reset --hard ad76ebf5ba8fb12bc38300ee99db478b332c1f7b 此操作成功以后 ...

  3. JAVA-错误The type BookServiceImpl must implement the inherited abstract method

    错误原因 :是因为class继承了其他的类,没有导入过来,选择add unimplemented methods进行解决

  4. Apache+wsgi+flask部署

    flask自带的web server是开发用途,并不适用与发布,需要借助专业的web服务器. 配置的坑无数,Apache部署,403禁止,莫名其妙无法访问,500内部错误把我搞得崩溃了. 重点参考: ...

  5. [Docker] Driver Bridge network for linking containers

    In previous postwe have seen how to link two container together by using `--link`: # docker run -d - ...

  6. NSLayoutConstraint的简单应用

    UIView *topView = [[UIView alloc] init]; topView.backgroundColor = [UIColor redColor]; [self.view ad ...

  7. springboot结合jwt实现基于restful接口的身份认证

    基于restful接口的身份认证,可以采用jwt的方式实现,想了解jwt,可以查询相关资料,这里不做介绍~ 下面直接看如何实现 1.首先添加jwt的jar包,pom.xml中添加依赖包: <de ...

  8. android中去掉ListView控件中的分割线

    通过设置android:divider="@null" ,可以去掉ListView控件中的分割线 也可以自定义分割线的颜色,比如: <ListView android:id= ...

  9. iOS 中基础字符判断函数收集(如判断大小写、数字等)

    函数:isdigit 用法:#include 功能:判断字符c是否为数字 说明:当c为数字0-9时,返回非零值,否则返回零. 函数:islower 用法:#include 功能:判断字符c是否为小写英 ...

  10. asp.net 定时执行任务代码 定时采集数据

    using System; using System.Data; using System.Configuration; using System.Collections; using System. ...