我已经使用sbt创建了一个项目,因此配置它:
val scalatest = "org.scala-tools.testing" % "scalatest" % "0.9.5" % "test"
然后我将示例从ScalaTest粘贴到一个文件中并运行“sbt test”以查看它是否正常工作.文件编译,但测试永远不会执行.
据我所知,这就像它的意思一样简单.我错过了什么吗?
最佳答案 首先,我相信1.0是根据他们的网站正确的版本.我的project / build / def.scala看起来像这样:
import sbt._
class Tests(info: ProjectInfo) extends DefaultProject(info) {
val scalatest = "org.scalatest" % "scalatest" % "1.0" % "test"
}
然后做一个sbt更新,然后sbt重新加载(不确定重新加载是否必要,但它没有伤害)
现在在/ src / test / scala中,使用他们的示例,但也导入scala.collection.mutable.Stack
和sbt测试对我来说很好
jcdavis@seam-carver:~/dev/test2$sbt test
Building project test 1.0 using Tests
with sbt 0.5.6 and Scala 2.7.7
== compile ==
Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed.
Compiling main sources...
Nothing to compile.
Post-analysis: 0 classes.
== compile ==
== copy-test-resources ==
== copy-test-resources ==
== copy-resources ==
== copy-resources ==
== test-compile ==
Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed.
Compiling test sources...
Nothing to compile.
Post-analysis: 4 classes.
== test-compile ==
== test-start ==
== test-start ==
== StackSpec ==
A Stack
Test Starting - A Stack should pop values in last-in-first-out order
Test Succeeded - A Stack should pop values in last-in-first-out order
Test Starting - A Stack should throw NoSuchElementException if an empty stack is popped
Test Succeeded - A Stack should throw NoSuchElementException if an empty stack is popped
== StackSpec ==
== test-complete ==
== test-complete ==
== test-finish ==
Run: 2, Passed: 2, Errors: 0, Failed: 0
All tests PASSED.
== test-finish ==
== test-cleanup ==
== test-cleanup ==
== test ==
== test ==
Successful.