我希望仅在使用IntegrationDebug配置时挂起派生的vm并等待来自外部调试器的连接。
参考http://www.scala-sbt.org/1.x/docs/Testing.html中的“共享源代码”部分,我提出了以下配置:
import sbt.Keys._
lazy val IntegrationDebug = config("itd") extend (IntegrationTest)
val scalaTestV = "3.0.4"
lazy val root = project.in(file("."))
.configs(
IntegrationTest,
IntegrationDebug
)
.settings(
Defaults.itSettings,
inConfig(IntegrationDebug)(Defaults.testTasks),
libraryDependencies ++= Seq(
"org.scalactic" %% "scalactic" % scalaTestV,
"org.scalatest" %% "scalatest" % scalaTestV,
),
fork in IntegrationTest := true,
javaOptions in IntegrationDebug += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8123",
)然而,它并没有像预期的那样工作:
it:test -> vm not suspended (expected)
itd:test -> vm not suspended (unexpected!!)如果我将javaOptions的作用域更改为IntegrationTest,即
...
javaOptions in IntegrationTest += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8123",
...然后
it:test -> vm suspended (unexpected!!)
itd:test -> vm suspended (expected)有没有办法让它像这样工作:
it:test -> vm not suspended
itd:test -> vm suspended发布于 2018-06-03 10:30:49
好吧,如果我没记错的话,我可能已经找到了这个问题的解决方案。
替换行:
javaOptions in IntegrationDebug += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8123",使用
testOptions in IntegrationDebug += Tests.Argument("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8123")应该可以做到这一点(在本例中,VM仅因itd:test命令而挂起)。
我知道已经很长时间了,但是有人可能会发现这很有用。我几乎也有同样的问题,这就是为我解决这个问题的原因。
https://stackoverflow.com/questions/47172446
复制相似问题