Frage

Ich habe verwendet sbt ein Projekt zu erstellen, ist es auf diese Weise konfiguriert:

val scalatest = "org.scala-tools.testing" % "scalatest" % "0.9.5" % "test"

Ich klebte dann das Beispiel von ScalaTest in eine Datei und lief „sbt Test“, wenn es zu sehen arbeitete. Die Datei kompiliert, aber der Test wird nie ausgeführt.

Soweit ich das beurteilen kann, ist dies so einfach wie es sein sollte ist. Bin ich etwas fehlt?

War es hilfreich?

Lösung

Zunächst einmal, ich glaube, 1.0 ist die richtige Version nach ihrer Website. Meine project/build/def.scala sieht wie folgt aus:

import sbt._

class Tests(info: ProjectInfo) extends DefaultProject(info) {
  val scalatest = "org.scalatest" % "scalatest" % "1.0" % "test"
}

Dann ein sbt update tun, dann einem sbt reload (nicht sicher, dass das Nachladen ist notwendig, aber es tut nicht weh)

Jetzt in /src/test/scala, nutzen ihr Beispiel, aber auch Import scala.collection.mutable.Stack und sbt test funktioniert gut für mich

jcdavis@seam-carver:~/dev/test2$ sbt test
[info] Building project test 1.0 using Tests
[info]    with sbt 0.5.6 and Scala 2.7.7
[info] 
[info] == compile ==
[info]   Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[info] Nothing to compile.
[info]   Post-analysis: 0 classes.
[info] == compile ==
[info] 
[info] == copy-test-resources ==
[info] == copy-test-resources ==
[info] 
[info] == copy-resources ==
[info] == copy-resources ==
[info] 
[info] == test-compile ==
[info]   Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling test sources...
[info] Nothing to compile.
[info]   Post-analysis: 4 classes.
[info] == test-compile ==
[info] 
[info] == test-start ==
[info] == test-start ==
[info] 
[info] == StackSpec ==
[info] A Stack
[info] Test Starting - A Stack should pop values in last-in-first-out order
[info] Test Succeeded - A Stack should pop values in last-in-first-out order
[info] Test Starting - A Stack should throw NoSuchElementException if an empty stack is popped
[info] Test Succeeded - A Stack should throw NoSuchElementException if an empty stack is popped
[info] == StackSpec ==
[info] 
[info] == test-complete ==
[info] == test-complete ==
[info] 
[info] == test-finish ==
[info] Run: 2, Passed: 2, Errors: 0, Failed: 0
[info]  
[info] All tests PASSED.
[info] == test-finish ==
[info] 
[info] == test-cleanup ==
[info] == test-cleanup ==
[info] 
[info] == test ==
[info] == test ==
[success] Successful.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top