【发布时间】:2018-06-18 11:09:58
【问题描述】:
[更新:问题原因找到了!阅读下文]
问题:VSTS Maven 构建似乎没有运行 JUnit,没有显示任何 JUnit 结果,似乎没有生成任何 JUnit 测试报告。
在 VSTS 中,我们有一个带有 Contact 和 TestContact 类以及 1 个测试用例的 Java 项目;
source\module\src\main\java\nl\customer\model\situation\Contact.java
source\module\src\test\java\nl\customer\model\ContactTest.java
source\module\pom.xml
从 Eclipse 运行 Maven 工作正常。控制台显示 Maven 使用 Surefire 报告,运行/通过 1 个单元测试。
在 Windows PC 上使用 Maven 运行项目也可以:
mvn test
日志记录:
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Domain Model
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ module ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 30 resources
[INFO] skip non existing resourceDirectory C:\project\source\projectdomain\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ module ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ module ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\project\source\module\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ module ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ module ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running nl.customer.module.ContactTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in nl.customer.module.ContactTest
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.109 s
[INFO] Finished at: 2018-01-09T14:05:03+01:00
[INFO] Final Memory: 10M/196M
[INFO] ------------------------------------------------------------------------
在 VSTS 中,使用 Maven 构建步骤(目标:安装)成功,但日志未显示有关 JUnit 的任何内容,即使 system.debug = true。
因此,尝试“发布测试结果”总是失败(无论是在使用单独的构建任务还是在 maven 构建任务中使用发布 TFS 选项时)。
【问题讨论】:
标签: maven unit-testing junit azure-devops