2010-04-22 42 views
4

我用SBT創建一個項目,配置它正是如此:Scala的簡單構建工具不會出現運行測試

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

我然後粘貼例如,從ScalaTest到一個文件並運行「 sbt測試「來查看它是否工作。該文件編譯,但絕不會在執行測試。

據我所知,這是簡單,因爲它的意思是。我錯過了什麼嗎?

+0

只是爲了確保,你將在Maven的正確路徑的測試文件? – 2010-04-22 15:24:11

回答

2

首先,我認爲1.0是根據他們的網站的正確版本。我project/build/def.scala看起來是這樣的:

import sbt._ 

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

然後做一個sbt update,然後sbt reload(不知道重裝是必要的,但它不會傷害)在/src/test/scala現在

,用自己的例子,但也進口scala.collection.mutable.Stacksbt test工作正常,我

[email protected]:~/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. 
相關問題