【问题标题】:VSTS Maven build - no JUnit tests runVSTS Maven 构建 - 不运行 JUnit 测试
【发布时间】: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


    【解决方案1】:

    看来我已经找到问题的原因了:在VSTS中,Maven构建任务有选项

    Set MAVEN_OPTS to
    

    在我们的构建定义中,这被设置为

    -Xmx1024m -X
    

    第一个参数是正确的,它设置了最大内存。 第二个参数不正确。如果你想让 Maven 给出调试输出,你应该把“-X”参数放在 Goal(s) 下。

    日志中没有关于第二个参数的真正警告。

    【讨论】:

    • 感谢您在此处分享您的解决方案,如果可能,您可以将其标记为答案,这样可以帮助遇到与您相同问题的其他社区成员。祝你有美好的一天:)
    猜你喜欢
    • 2016-03-09
    • 2010-09-30
    • 2013-08-23
    • 2013-11-08
    • 2021-12-16
    • 2011-09-04
    相关资源
    最近更新 更多