如何连接Scala Intellij调试器进行测试? [英] How do you attach the Scala Intellij debugger for tests?
问题描述
将IntelliJ调试器配置为附加到sbt管理的scala Play测试需要什么步骤?
What steps are needed to configure the IntelliJ debugger to attach to scala Play tests managed by sbt?
在IntelliJ 2019中,您可以使用sbt shell中的调试按钮将调试器附加到sbt run
命令,而无需进行配置更改.
但是,调试器不会附加到test
命令.
In IntelliJ 2019, you can attach the debugger to the sbt run
command using the debug button in the sbt shell with no configuration changes.
However, the debugger does not attach to the test
command.
推荐答案
Consider attaching the debugger via IntelliJ's sbt shell:
- 在 sbt项目工具中窗口选中复选框
Use sbt shell for builds
- 打开 sbt shell 工具窗口(通常在底部)
- 单击
Attach debugger to sbt shell
按钮(该图标看起来像个错误) - 在状态栏中,应显示
Connected to the target VM
(请参见下面的图片) - 在测试中设置断点
- 在 sbt shell 工具窗口中执行
test
命令 - 调试sbt shell 窗口应打开,执行应在第一个断点处停止.
- In the sbt projects tool window select checkbox
Use sbt shell for builds
- Open sbt shell tool window (usually found at the bottom)
- Click
Attach debugger to sbt shell
button (the icon looks like a bug) - In the status bar it should say
Connected to the target VM
(see the image bellow) - Set breakpoints in your test
- Execute
test
command in the sbt shell tool window - Debug sbt shell window should open and execution should stop at the first breakpoint.
请注意,如果您像OP一样使用Play,则默认情况下,Play会在
Note if you are using Play like OP, then by default Play runs tests in forked JVM, so for the above technique to work try setting Test / fork := false
in build.sbt
.
这篇关于如何连接Scala Intellij调试器进行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!