如何使用Play调试测试! 2.0 [英] How to debug tests with Play! 2.0

查看:137
本文介绍了如何使用Play调试测试! 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Play 2设置项目,我已经能够使用eclipse远程调试来调试webapp。虽然,我也想在我的测试中使用断点。有没有人知道设置单元如何测试远程调试?

I am setting up a project using Play 2 and I am already able to debug the webapp using eclipse remote debugging. Though, I'd also like to use breakpoints along my tests. Does anyone know how setup unit tests' remote debugging?

推荐答案

这是发生的,因为Play(SBT)无需远程调试所需的选项。您至少有两个选项:禁用新的JVM的fork,将额外的选项传递给用于测试的JVM。

This is happening since Play (SBT) forks separate JVM for tests, without options needed for remote debug. You have at least two options: disable fork of new JVM, pass additional options to JVM used for tests.

要禁用fork,请修改Build.scala,添加 fork in(Test):= false ,请参阅下面完整的Build.scala示例:

To disable fork, modify Build.scala, add fork in (Test) := false, see full Build.scala example below:

import sbt._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "so1"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    javaCore,
    javaJdbc,
    javaEbean
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here
    Keys.fork in (Test) := false
  )
}

要传递其他选项,添加可以使用代码:

To pass additional options, add you can use this code:

  val main = play.Project(appName, appVersion, appDependencies).settings(
    Keys.javaOptions in (Test) += 
    "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9998"
  )

您将需要配置IDE以使用端口9998附加到测试。
此外,每次运行测试时,您都需要重新附加调试器,这可能不方便。

You will need to configure your IDE to use port 9998 to attach to tests. Also, you will need to re-attach debugger each time when you run tests, that could be inconvenient.

这篇关于如何使用Play调试测试! 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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