maven - 如何让 Maven Surefire 退出当前正在寻找测试的位置?
问题描述
当我无法正确找到我的路径时,我从 Maven Surefire 获取以下日志。有没有办法让它吐出testSourceDirectory
设置的目录?
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) @ project ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.549 s
[INFO] Finished at: 2018-08-02T19:31:08-04:00
[INFO] ------------------------------------------------------------------------
我的 pom.xml
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration />
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</plugin>
我的源代码在src/main/java/org/company/project
.
我的测试在src/test/java/org/company/project
我用来设置 pom.xml 的教程:https ://howtoprogram.xyz/2016/09/09/junit-5-maven-example/
我可以在这个项目中使用这个 pom.xml 成功运行测试:https ://github.com/junit-team/junit5-samples/tree/r5.2.0/junit5-jupiter-starter-maven 。但是当我将它转移到我自己的项目中时,它无法获得任何规范。
编辑:显然我们正在使用spring-boot-starter-test
,它只使用 JUnit 4。使用https://info.michael-simons.eu/2018/06/18/maven-use-junit-5-with-spring-boot-for-unit- and-integration-tests/看看我是否可以使用 JUnit 5。
解决方案
运行测试时,尝试将 -X 参数添加到 maven
mvn -X test
并查找您要询问的参数。在我的环境中,它的价值是
[DEBUG] (s) testSourceDirectory = C:\Users\ME\MyWork\workspace\MyProject\src\test\java
希望这可以帮助。
推荐阅读
- python - 如何在张量流中窗口化或重置流操作?
- android - 布局被按钮重叠。如何隐藏按钮?
- c# - wix卸载程序(exe)如何删除自身
- python - Python:无法导入仅包含静态方法的两个相互依赖的类
- javascript - 使用后退按钮时恢复角度控制器中的过滤状态?
- javascript - 将对象数组转换为网格可读数组
- angular - 从角度 4 中的另一个组件更改布尔值
- google-app-engine - 到第一代 CloudSQL 的 GAE flex 连接字符串
- java - 抽象类构造函数实际使用
- cordova - 无法在 Quickblox Javascript 中接听视频通话