如何连接Scala Intellij调试器进行测试? [英] How do you attach the Scala Intellij debugger for tests?

查看:277
本文介绍了如何连接Scala Intellij调试器进行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将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.

推荐答案

请考虑通过IntelliJ的

Consider attaching the debugger via IntelliJ's sbt shell:

  1. sbt项目工具中窗口选中复选框Use sbt shell for builds
  2. 打开 sbt shell 工具窗口(通常在底部)
  3. 单击Attach debugger to sbt shell按钮(该图标看起来像个错误)
  4. 状态栏中,应显示Connected to the target VM(请参见下面的图片)
  5. 在测试中设置断点
  6. sbt shell 工具窗口中执行test命令
  7. 调试sbt shell 窗口应打开,执行应在第一个断点处停止.
  1. In the sbt projects tool window select checkbox Use sbt shell for builds
  2. Open sbt shell tool window (usually found at the bottom)
  3. Click Attach debugger to sbt shell button (the icon looks like a bug)
  4. In the status bar it should say Connected to the target VM (see the image bellow)
  5. Set breakpoints in your test
  6. Execute test command in the sbt shell tool window
  7. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆