【问题标题】:ScalaTest I get error while loading Suite, Scala signature Suite has wrong versionScalaTest 加载套件时出错,Scala 签名套件的版本错误
【发布时间】:2016-05-13 11:45:31
【问题描述】:

我有一个依赖的maven项目:

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

并且有一个像这样的测试类套件:

import java.util.{LinkedHashMap => jLinkedHashMap, ArrayList => jArrayList, Arrays}
import org.scalatest._


class NeutralizeEITSuite extends FunSuite with Matchers {

    val nEIT = new NeutralizeEIT()

    test("Valid content category 'MiniSeries' is neutralized to 'TV Entertainment':") {
        val result = neutralizedEIT(content_category = "MiniSeries")
        val content_category = getStringValueFromEIT("content_category", result)
        content_category should equal ("TV Entertainment")
    }
}

编译过程中出现我不理解的错误:

[INFO] includes = [**/*.scala,**/*.java,]
[INFO] excludes = []
[INFO] C:\PROJECTS\active\Farallon\Hyperion\master\src\test\java:-1: info: compiling
[INFO] Compiling 10 source files to C:\PROJECTS\active\Farallon\Hyperion\master\target\test-classes at 1454551605523
[ERROR] error: error while loading Suite, Scala signature Suite has wrong version
[INFO]  expected: 5.0
[INFO]  found: 4.1 in Suite.class
[ERROR] C:\PROJECTS\active\Farallon\Hyperion\master\src\test\java\com\mycompany\ese\ingest\NeutralizeEITSuite.scala:9: error: illegal inheritance;
[INFO]  self-type com.mycompany.ese.ingest.neutralizeEITSuite does not conform to org.scalatest.FunSuite's selftype org.scalatest.FunSuite
[INFO] class neutralizeEITSuite extends FunSuite with Matchers {
[INFO]                                  ^
[ERROR] C:\PROJECTS\active\Farallon\Hyperion\master\src\test\java\com\mycompany\ese\ingest\NeutralizeEITSuite.scala:9: error: illegal inheritance;
[INFO]  self-type com.mycompany.ese.ingest.neutralizeEITSuite does not conform to org.scalatest.Matchers's selftype org.scalatest.Matchers
[INFO] class neutralizeEITSuite extends FunSuite with Matchers {
[INFO]                                                ^
[ERROR] C:\PROJECTS\active\Farallon\Hyperion\master\src\test\java\com\mycompany\ese\ingest\NeutralizeEITSuite.scala:15: error: recursive value result needs type
[INFO]         val content_category = getStringValueFromEIT("content_category", result)

我试过用谷歌搜索错误,但没有结果。我的 pom.xml 中没有额外的 org.scalatest 依赖项

FunSuite 4.1 和 5.0 版在哪里?

谢谢,

【问题讨论】:

    标签: scala maven dependencies scalatest test-suite


    【解决方案1】:

    content_category 变量可能与之前行中的content_category 命名参数冲突。

    【讨论】:

    • 这确实帮助了最后一个错误,但我的主要问题是这一行:error: error while loading Suite, Scala signature Suite has wrong version 它正在加载哪个版本?有冲突吗?我的一些依赖项似乎依赖于 scalatest 0.9。这会导致它吗?
    【解决方案2】:

    通过在我的 pom 中更新 scala specs 依赖项解决了问题

    来自

        <dependency>
            <groupId>org.specs</groupId>
            <artifactId>specs</artifactId>
            <version>1.6.2.2_1.5.0</version>
            <scope>test</scope>
        </dependency>
    

        <dependency>
            <groupId>org.scala-tools.testing</groupId>
            <artifactId>specs</artifactId>
            <version>1.6.2.2_1.5.0</version>
        </dependency>
    

    【讨论】:

      【解决方案3】:

      5 年后我来到了这里,所以对于通过谷歌到达这里的任何人......这些天的答案是你的 pom.xml 中可能有一个旧版本的 org.specs(可能是因为你复制和粘贴来自旧源),以及新的 org.scalatest 库。

      如果两者都有,解决方法是删除它:

      <dependency>
        <groupId>org.specs</groupId>
        <artifactId>specs</artifactId>
        <version>[Some version]</version>
        <scope>test</scope>
      </dependency>
      

      只留下这个:

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

      (_2.11 替换为您正在使用的 Scala 版本,3.2.9 替换为您正在使用的 ScalaTest 版本。)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-27
        • 2017-02-14
        • 2013-09-21
        • 2020-12-20
        • 2016-03-29
        • 1970-01-01
        • 2016-08-28
        • 1970-01-01
        相关资源
        最近更新 更多