zoukankan      html  css  js  c++  java
  • maven中跳过单元测试

    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
  • 相关阅读:
    Linux使用locate命令定位文件
    LINUX常用命令
    linux性能问题(CPU,内存,磁盘I/O,网络)
    Linux下常用的shell命令记录
    Linux下的进程管理
    Linux常用性能检测命令解释
    CentOS查看系统信息-CentOS查看命令
    linux系统中如何查看日志 (常用命令)
    美团HD(4)-二级联动效果
    美团HD(3)-加载分类导航数据
  • 原文地址:https://www.cnblogs.com/amosli/p/3573499.html
Copyright © 2011-2022 走看看