spring-boot - 调试器、@SpringBootTest 和 Gradle
问题描述
我是 Spring Boot 和 Gradle 的新手,无法弄清楚如何暂停 JUnit 测试并使用调试器连接到它们。
我在命令行上调用自动化测试gradlew build
。我想要的是在它到达测试任务并等待调试器连接时暂停执行。
JUnit 测试类的注释如下:
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("test")
@AutoConfigureMockMvc
我已经尝试将用于调试的 JVM 参数添加到 gradle.properties 文件中,但我仍然无法让它暂停,更不用说在调试器的端口上监听了。我不确定要为您提供什么信息——请在评论中询问我的文件、代码或设置。
- 摇篮 5.5
- 春季启动 2.16
- 爪哇 11
解决方案
@奥米德。谢谢你的链接。解决方案很简单。
更新:不要使用gradlew build
. 改为使用该test
任务。
gradlew test --debug-jvm
在 Gradle 5.5.1 文档中: https ://docs.gradle.org/current/userguide/java_testing.html#sec:debugging_java_tests
推荐阅读
- c# - wpf virtualizingstackpanel在不同Win10机器上的不同行为
- html - 当有多个同名输入时,MVC 如何决定绑定哪个值?
- python - 带有 Tensorflow 数据集 API 的 Keras 生成器 - IndexError:从空列表中弹出
- augmented-reality - 如何测试 ARKit 应用程序?可以使用录制的视频而不是实时视频来测试 ARKit 应用程序吗?
- excel - 如何使用“COUNTIF”函数计算每行的一个实例
- c# - 在 Xamarin.Forms 中单击项目的 BoxView 获取 ListView 项目的 ID
- python - 使用 Python 3 和 Tkinter 制作 GUI 文件下载器
- webpack - 无效的配置对象。网页包
- android - 切换按钮更改颜色
- excel - SUMIF NOT 范围在范围内