如何使用 Maven 插件通过 JUnit 测试运行 Scalatest

igx*_*igx 5 junit scala maven scalatest maven-surefire-plugin

我正在使用 scala 编写一些测试到 java maven 项目。我想使用 Maven 插件运行这些测试,但我还希望其余的 JUnit 测试也能运行。问题是,根据本指南, 我必须禁用 Surefire 。我有一个同时运行 scalatest 和 junit 测试的解决方案吗?

Til*_*ann 1

您可以使用 Maven Surefire 插件运行 scalatest。您只需指定使用JUnitRunnervia 注释即可运行 scalatest。

@RunWith(classOf[JUnitRunner])
class MyTest extends FunSuite with Matchers {
  test("foobar") {
    true should be(true)
  }
}
Run Code Online (Sandbox Code Playgroud)