Scala 的 simple-build-tool 似乎没有运行测试

发布于 2024-08-30 08:38:36 字数 299 浏览 7 评论 0原文

我使用 sbt 创建了一个项目,并对其进行了如下配置:

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

然后,我将 ScalaTest 中的示例粘贴到文件并运行“sbt test”以查看它是否正常工作。文件编译,但测试从未执行。

据我所知,这很简单。我错过了什么吗?

I've used sbt to create a project, configured it thusly:

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

I then pasted the example from ScalaTest into a file and ran "sbt test" to see if it was working. The file compiles, but the test is never executed.

As far as I can tell, this is as simple as it's meant to be. Am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹梦 2024-09-06 08:38:36

首先,根据他们的网站,我相信 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.Stack
sbt test 对我来说效果很好

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.

first off, I believe 1.0 is the correct version according to their website. My project/build/def.scala looks like this:

import sbt._

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

Then do a sbt update, then a sbt reload (not sure the reload is necessary, but it doesn't hurt)

Now in /src/test/scala, use their example but also import scala.collection.mutable.Stack
and sbt test works fine for me

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文