Maven surefire插件不运行我们的Unit测试用例

时间:2018-05-04 18:46:11

标签: maven maven-2

Apache Maven 3.5.2 - pom.xml没有明确声明surefire插件,但有效的pom.xml显示为2.18.1

当我跑'mvn test' - 它成功结束,它没有说它找不到任何测试用例,但没有测试用例的痕迹。这就是我所看到的:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpreadSheetUploadWeb 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.fasterxml.jackson.core:jackson-databind:jar:1.9.10 is missing, no dependency information available
[WARNING] The POM for com.fasterxml.jackson.core:jackson-annotations:jar:1.9.10 is missing, no dependency information available
[WARNING] The POM for com.fasterxml.jackson.core:jackson-core:jar:1.9.10 is missing, no dependency information available
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SpreadSheetUploadWeb ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 22 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SpreadSheetUploadWeb ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SpreadSheetUploadWeb ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SpreadSheetUploadWeb ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ SpreadSheetUploadWeb ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

我的pom.xml指定了jar,我的测试用例位于:

C:/SpreadSheetUploadWeb/src/test/java/com/ibm/cio/cloud/cost/spreadsheet/dao/UnitTestJdbcCostSpreadsheetDAO.java

当我像这样明确地运行测试时它完美地工作:

mvn surefire:test -Dtest=UnitTestJdbcCostSpreadsheetDAO.java

为什么在我刚运行时不会运行:mvn test?

1 个答案:

答案 0 :(得分:0)

默认情况下,surefire会搜索以下模式后的文件:

** /试验*的.java

** / * Test.java

** / * Tests.java

** / * TestCase.java

http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html