如何指示 sbt 0.11.x 哪些源文件包含测试

发布于 2024-12-18 23:00:41 字数 849 浏览 2 评论 0原文

我是 Scala、SBT 和 Specs 的新手。我使用规范创建了一个简单的规范,并希望通过 SBT 的“测试”任务来运行它。当我执行该任务时,出现以下错误:

> test
[info] No tests to run for test:test
[success] Total time: 0 s, completed Nov 30, 2011 4:27:38 PM

我知道我必须告诉 SBT 我的哪些文件是测试文件。我在 SBT 主页和 Stackoverflow 上找到的唯一示例是

override def includeTest(s: String) = { s.endsWith("Spec") }

我包含在 Build.scala 文件中的这段代码。然而,这似乎不再适用于 SBT 0.11.x。我收到以下编译错误

[info] Compiling 1 Scala source to /Users/gruetter/Workspaces/scala/helloscala/project/target/scala-2.9.1/sbt-0.11.1/classes...
[error] /Users/gruetter/Workspaces/scala/helloscala/project/Build.scala:4: method includeTest overrides nothing
[error]     override def includeTest(s: String) = { s.endsWith("Spec") }

有人知道新的 SBT 版本是如何完成此操作的吗?

预先感谢您的帮助!

干杯, 格奥尔格

I'm new to Scala, SBT and Specs. I have created a simple specification using specs and like to run it via SBT with the "test" task. When I execute that task, I get the following error:

> test
[info] No tests to run for test:test
[success] Total time: 0 s, completed Nov 30, 2011 4:27:38 PM

I understand that I have to tell SBT which of my files are test files. The only example I have found on the SBT homepage and on Stackoverflow is this piece of code

override def includeTest(s: String) = { s.endsWith("Spec") }

which I included in my Build.scala file. It seems, however, that this does no longer work with SBT 0.11.x. I get the following compilation error

[info] Compiling 1 Scala source to /Users/gruetter/Workspaces/scala/helloscala/project/target/scala-2.9.1/sbt-0.11.1/classes...
[error] /Users/gruetter/Workspaces/scala/helloscala/project/Build.scala:4: method includeTest overrides nothing
[error]     override def includeTest(s: String) = { s.endsWith("Spec") }

Does anybody know how this is done with the new SBT version?

Thanks in advance for your help!

Cheers,
Georg

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

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

发布评论

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

评论(1

夏有森光若流苏 2024-12-25 23:00:41

将用于测试的 .scala 文件放在 $project/src/test/scala 而不是 $project/src/main/scala 中

Put the .scala files for tests in $project/src/test/scala instead of $project/src/main/scala

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