ScalaTest Spec Kompilierungsfehler
Ich bin neu in Scala und ich bin versucht,ScalaTest. Ich umfasste seine Abhängigkeit in meinem build.sbt-Datei als
libraryDependencies++=Seq(
"org.scalatest" % "scalatest_2.11" % "2.1.7" % "test"
)
und erfrischt sbt und nun scheint es in meiner Externen Bibliotheken-Ordner, so denke ich, dass es richtig installiert wurde. Jetzt möchte ich eine test-Klasse. So habe ich eine erstellt unter src/test/scala. Ich benutzte das Beispiel von ScalaTest website frontpage die
import collection.mutable.Stack
import org.scalatest._
class ExampleSpec extends FlatSpec with Matchers {
"A Stack" should "pop values in last-in-first-out order" in {
val stack = new Stack[Int]
stack.push(1)
stack.push(2)
stack.pop() should be (2)
stack.pop() should be (1)
}
it should "throw NoSuchElementException if an empty stack is popped" in {
val emptyStack = new Stack[Int]
a [NoSuchElementException] should be thrownBy {
emptyStack.pop()
}
}
}
Jedoch wenn ich diese Klasse bekomme ich die Fehlermeldung
Error:scalac: bad symbolic reference. A signature in package.class refers to type compileTimeOnly
in package scala.annotation which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.
und auch
Error:(4, 27) Reference to class FlatSpec in package scalatest should not have survived past type checking,
it should have been processed and eliminated during expansion of an enclosing macro.
class ExampleSpec extends FlatSpec with Matchers {
^
Könnte mir jemand sagen, was das problem ist. Wie es aussieht ist es nicht zu erkennen, ScalaTest. Allerdings ist es in meinen Externen Bibliotheken und IntelliJ auto-complete zeigt auch, dass es da ist. Kann ich das irgendwie aktualisieren müssen, etwas anderes, bevor ich beginne tatsächlich mit ScalaTest?
EDIT:
Auch wenn ich test:compile
von sbt, die ich bekommen
[error] error while loading package, class file needed by package is missing.
[error] reference value <init>$default$2 of object deprecated refers to nonexisting symbol.
[error] error while loading Matchers, class file needed by Matchers is missing.
[error] reference value <init>$default$2 of object deprecated refers to nonexisting symbol.
[error] error while loading Assertions, class file needed by Assertions is missing.
[error] reference value internal of package scala.reflect.macros refers to nonexisting symbol.
[error] error while loading AbstractSuite, class file needed by AbstractSuite is missing.
[error] reference value <init>$default$2 of object deprecated refers to nonexisting symbol.
[error] error while loading Tolerance, class file needed by Tolerance is missing.
[error] reference value <init>$default$2 of object deprecated refers to nonexisting symbol.
[error] error while loading BeWord, class file needed by BeWord is missing.
[error] reference value <init>$default$2 of object deprecated refers to nonexisting symbol.
[error] error while loading ResultOfNotWordForAny, class file needed by ResultOfNotWordForAny is missing.
[error] reference value <init>$default$2 of object deprecated refers to nonexisting symbol.
[error] error while loading NotWord, class file needed by NotWord is missing.
[error] reference value <init>$default$2 of object deprecated refers to nonexisting symbol.
[error] 8 errors found
[error] (test:compile) Compilation failed
- haben Sie versucht
;reload; clean; test:compile
? - Ich nur eingebaut, die Fehler aus
test:compile
. Es sieht aus wie ScalaTest ist nicht korrekt installiert... - zu auto-match der scalaVersion (ich nehme an, Sie verwenden 2.11.x) Sie besser schreiben
libraryDependencies ++= Seq("org.scalatest" %% "scalatest" % "2.1.7" % "test")
- Das schafft eine nicht aufgelöste Abhängigkeit. ` [Fehler] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.9.2;2.1.7: nicht gefunden [Fehler] Gesamt-Zeit: 0 s, abgeschlossen 31-Mai-2014 7:06:20 Uhr `
- möglich, Duplikat der Warum sbt sagen, "bad symbolische Referenz..." zum testen mit ScalaTest?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Es scheint SBT versucht zu kompilieren gegen scala 2.9.2.
Ich vermute, Sie haben zum hinzufügen von
oder
Ihrem
build.sbt
und natürlich
Zusätzlich können Sie versuchen, die neueste SBT launcher.
scalaVersion := "2.11.1"
scheint gewirkt zu haben, daß die tests, die von innen IntelliJ. Allerdings, wenn ichtest:compile
es noch schafft einen Fehler[info] 'compiler-interface' not yet compiled for Scala 2.11.1. Compiling... [error] (compile:compile) Error compiling sbt component 'compiler-interface'
So, ich nehme Ihre Antwort, aber könntest du erraten, warum dieser Fehler Auftritt?scalaVersion := "2.11.2"
zu bauen.sbt). Weder die Fehlermeldung, noch das Update ist sehr klar, obwohl. Ich mag es nicht.Und wenn Sie brauchen, um zu kompilieren mit scala
2.9
dann aktualisiertJAVA_HOME
undIDEA_JDK
zeigenjdk1.7
stattjdk1.8