【发布时间】:2013-09-14 12:04:36
【问题描述】:
在 sbt 中进行基于 specs2 的测试的方法是
(testOptions in Test) += Tests.Argument(TestFrameworks.Specs2, "html")
但是 scalatest 怎么样?我做了很多谷歌搜索,但找不到好的解释/解决方案。
【问题讨论】:
标签: scala sbt scalatest specs2
在 sbt 中进行基于 specs2 的测试的方法是
(testOptions in Test) += Tests.Argument(TestFrameworks.Specs2, "html")
但是 scalatest 怎么样?我做了很多谷歌搜索,但找不到好的解释/解决方案。
【问题讨论】:
标签: scala sbt scalatest specs2
所以我需要做两件事......
我。使用 2.0.M5b 之后的任何 scalatest 工件。对我来说,我添加了这个依赖项,
org.scalatest" %% "scalatest" % "2.0.M6" % "test->*" excludeAll (
ExclusionRule(organization="org.junit", name="junit")
)
"test->*" 是必需的,否则将不会下载生成 html 所需的依赖项。 (一定有比这更好的办法)
二。在 build.sbt 中添加
(testOptions in Test) += Tests.Argument(TestFrameworks.ScalaTest, "-u", "target/report")
【讨论】:
Symbol 'type org.scalactic.TripleEquals' is missing from the classpath. 它还抱怨 Tolerance 和 term org.scalactic.source。知道如何为 3.0 更新这个吗?
注意该设置。
org.scalatest" %% "scalatest" % "2.0.M6" % "test->*
它提取了一些 ivy 无法解决的 junit:junit:3.8.1 依赖项。见this bug
这是在 ScalaTest 2.0 中更好的方法
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-u", "target/test-reports")
这在 Jenkins 中运行良好
【讨论】:
这是我的做法。
以这种方式更改您的build.sbt:
Test/testOptions := Seq(
Tests.Argument(TestFrameworks.ScalaTest, "-h", "target/scalatest")
),
projectDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.9" //% Test,
"com.vladsch.flexmark" % "flexmark" % "0.36.8" % Test,
"com.vladsch.flexmark" % "flexmark-profile-pegdown" % "0.36.8" % Test,
...
)
flexmark 依赖项没有记录,但它是必要的。
将在target/scalatest 目录中生成 HTML 报告。
您可以使用 Jenkins 发布它。
我用最新版本的 flexmark 进行了测试,但它不起作用。
【讨论】: