ScalaTest 加载套件时出现错误,Scala 签名套件版本错误
ScalaTest I get error while loading Suite, Scala signature Suite has wrong version
我有一个具有依赖项的 Maven 项目:
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>2.2.5</version>
<scope>test</scope>
</dependency>
然后像这样测试 class 套件:
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 版本在哪里?
谢谢,
content_category
变量可能与前一行的 content_category
命名参数发生冲突。
问题已通过更新我的 pom 中的 scala 规范依赖项得到修复
来自
<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>
我是在 5 年后来到这里的,所以对于通过 Google 到达这里的任何人......这些天的答案是你的 [=] 中可能有旧版本的 org.specs 21=](可能是因为您从旧源复制粘贴),以及新的 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 版本。)
我有一个具有依赖项的 Maven 项目:
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>2.2.5</version>
<scope>test</scope>
</dependency>
然后像这样测试 class 套件:
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 版本在哪里?
谢谢,
content_category
变量可能与前一行的 content_category
命名参数发生冲突。
问题已通过更新我的 pom 中的 scala 规范依赖项得到修复
来自
<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>
我是在 5 年后来到这里的,所以对于通过 Google 到达这里的任何人......这些天的答案是你的 [=] 中可能有旧版本的 org.specs 21=](可能是因为您从旧源复制粘贴),以及新的 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 版本。)