mvn test 和mvn surefire:test 的区别

 mvn test  和 的区别  mvn surefire:test

以这两种方式运行它的区别在于:

mvn -Dtest=DatabaseTest test

mvn -Dtest=DatabaseTest surefire:test

我可以看到测试显示:

执行mvn test 执行的输出

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rac.mybatis ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ rac.mybatis ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rac.mybatis ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/etomort/smip/oracle-rac/mybatis-rac/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ rac.mybatis ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rac.mybatis ---
[INFO] Surefire report directory: /home/etomort/smip/oracle-rac/mybatis-rac/target/surefire-reports

surefire:test 的输出:

[INFO] --- maven-surefire-plugin:2.12.4:test (default-cli) @ rac.mybatis ---
[INFO] Surefire report directory: /home/etomort/smip/oracle-rac/mybatis-rac/target/surefire-reports

不同之处在于test运行完整构建到执行测试的点,而surefire:test仅执行测试,重新使用先前构建的中间结果。

所以,如果你是编辑测试并且只运行surefire:test,新版本的测试将不会被编译,因此Maven将执行一些旧版本的测试。一般来说,很难说以这种方式执行哪个版本的测试,因此这就是人们通常使用mvn clean test而不是mvn surefire:test的原因。

Surefire是官方测试插件,必将进入测试阶段。

上一篇:element-ui修改dialog样式全局、局部修改问题 el-dialog__title/el-dialog__header/el-dialog__body/el-dialog__footer


下一篇:封装dialog