首页 > 解决方案 > 如何使用 Mill 运行 JUnit 测试

问题描述

我有一些想要运行的 JUnit 测试。

sbt所要做的就是添加这个依赖:

"com.novocode" % "junit-interface" % "0.11" % "test"

根据Mill 文档,您必须添加自定义框架,例如:

def testFrameworks = Seq("org.scalatest.tools.Framework", "WHAT GOES HERE?")

我需要做什么才能让我的 JUnit 测试正常工作?

标签: scalajunitmill

解决方案


在写这个问题时,我想通了:

build.sh你有:

  • 要添加此测试依赖项: ivy"com.novocode:junit-interface:0.11"
  • 添加这个测试框架: com.novocode.junit.JUnitFramework

然后整个组件看起来:

object myModule extends ScalaModule {
  def scalaVersion = "2.12.8"
  object test extends Tests {
    override def ivyDeps = Agg(
      ivy"org.scalatest::scalatest:3.0.5",
      ivy"com.novocode:junit-interface:0.11"
    )

    def testFrameworks = Seq("org.scalatest.tools.Framework", 
         "com.novocode.junit.JUnitFramework")
  }
}

推荐阅读