【问题标题】:Maven not running scala testsMaven 没有运行 Scala 测试
【发布时间】:2020-03-10 07:53:44
【问题描述】:

我在 pom 中有以下内容:

<dependency>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest_2.11</artifactId>
        <version>3.0.8</version>
        <scope>test</scope>
</dependency>

此外,按照here 记录的内容进行了更改。

并测试为:

class MyTest extends FunSuite {
    test("....") {
        assert(2+2 == 4)
    }
}

'mvn clean install' 的输出为:

测试运行:0,失败:0,错误:0,跳过:0

Maven 没有执行测试。为什么会这样?

【问题讨论】:

    标签: maven scalatest


    【解决方案1】:

    这不是您问题的答案,但应该允许您运行测试。

    您可以使用JUnitRunnersurefire 来运行您的测试。

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    ...
    <sourceDirectory>src/main/scala</sourceDirectory>
    <testSourceDirectory>src/test/scala</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>4.2.4</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
     ...
    

    然后在你的测试类上注解:

    @RunWith(classOf[JUnitRunner])
    class MyTest extends FunSuite {
    

    【讨论】:

      猜你喜欢
      • 2021-12-16
      • 2020-12-19
      • 2012-11-18
      • 2015-10-19
      • 2014-02-24
      • 2019-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多