【问题标题】:how to make scalatest generate html report through sbt如何通过 sbt 使 scalatest 生成 html 报告
【发布时间】:2013-09-14 12:04:36
【问题描述】:

在 sbt 中进行基于 specs2 的测试的方法是

(testOptions in Test) += Tests.Argument(TestFrameworks.Specs2, "html")

但是 scalatest 怎么样?我做了很多谷歌搜索,但找不到好的解释/解决方案。

【问题讨论】:

    标签: scala sbt scalatest specs2


    【解决方案1】:

    所以我需要做两件事......

    我。使用 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")

    【讨论】:

    • 这应该是 -h 用于 html 报告。 -u 是xml报告。
    • 这不适用于 Scalatest 3.0.7:Symbol 'type org.scalactic.TripleEquals' is missing from the classpath. 它还抱怨 Toleranceterm org.scalactic.source。知道如何为 3.0 更新这个吗?
    【解决方案2】:

    注意该设置。

    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 中运行良好

    【讨论】:

      【解决方案3】:

      这是我的做法。 以这种方式更改您的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 进行了测试,但它不起作用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-22
        • 2016-08-31
        • 2016-01-08
        • 2012-11-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-24
        相关资源
        最近更新 更多