其中-D的意思是 -D,--define <arg> Define a system property
执行特定的测试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
mvn test -Dtest=[ClassName]
mvn -Dtest=com.mamh.aais.aais.TriggerAndroidBuildTest test
------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.mamh.aais.aais.TriggerAndroidBuildTest [ info]lastbuild file: [/dailybuild/android/sdm660/LAST_BUILD.sdm660_nougat_20170308] last manifest file path: /dailybuild/android/sdm660/2017-08-03_sdm660_nougat_20170308/manifest.xml Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.121 sec - in com.mamh.aais.aais.TriggerAndroidBuildTest
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
使用逗号分割要测试的类
1 2 3 4 5 6
mvn -Dtest=com.mamh.aais.aais.TriggerAndroidBuildTest,com.mamh.aais.aais.AaisJenkinsTest test
# 也可以支持通配符的形式 mvn -Dtest=com.mamh.aais.aais.*Test test
使用#指定测试方法,使用*通配测试方法
1 2 3 4 5
mvn test -Dtest=[ClassName]#[MethodName]
mvn -Dtest=com.mamh.aais.aais.TriggerAndroidBuildTest#testGetLastBuildManifestFile test
使用+号指定一个类中的多个测试方法
1 2 3 4 5 6
mvn -Dtest=com.mamh.aais.aais.AaisGitTest#testLog+testRevParse test
mvn -Dtest=com.mamh.aais.aais.AaisGitTest#testLog+testRevParse,com.mamh.aais.aais.TriggerAndroidBuildTest#testGetLastBuildManifestFile test
[INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/mamh/github/ssh-slaves-plugin/target/target/generated-sources/localizer/hudson/plugins/sshslaves/Messages.java:[20,8] 类重复: hudson.plugins.sshslaves.Messages [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.996 s [INFO] Finished at: 2019-12-11T12:59:56+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project ssh-slaves: Compilation failure [ERROR] /home/mamh/github/ssh-slaves-plugin/target/target/generated-sources/localizer/hudson/plugins/sshslaves/Messages.java:[20,8] 类重复: hudson.plugins.sshslaves.Messages [ERROR] [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException