在 SBT 中为多个测试文件夹设置操作 [英] Setting up actions for multiple test folders in SBT
问题描述
关于上一个问题,我想为不同类型的测试设置多个测试文件夹,并且能够使用单独的 SBT 操作执行每个文件夹中包含的测试.
In relation to a previous question, I'd like to have multiple test folders for different types of test and be able to execute the tests contained in each folder with a separate SBT action.
例如,test-unit"操作将仅运行文件夹 src/test/scala/unit 下包含的测试,而test-functional"操作将仅运行测试在 src/test/scala/functional 下.我们将如何编写操作来执行此操作?
For example, an action 'test-unit' would run only the tests contained under the folder src/test/scala/unit, and a 'test-functional' action would run only the tests under src/test/scala/functional. How would we write actions to do this?
推荐答案
如果您使用的是 xsbt
0.10.0,您可以轻松创建 其他测试配置,方法是在 project
文件夹中的 Scala 文件中定义完整的构建配置.下面是集成测试的 wiki 示例.默认目录布局与您的略有不同,单元测试在 src/test/scala 中,集成测试在 src/it/scala 中.然后,您可以从控制台运行 test
来执行单元测试或运行 it:test
进行集成测试.
If you are using xsbt
0.10.0, you can easily create additional test configurations by defining the a full build configuration in a Scala file located in your project
folder. Below is the wiki example for integration tests. The default directory layout is a bit different from yours, unit tests go in src/test/scala and integration tests in src/it/scala. From the console, you can then run test
to execute unit tests or it:test
for integration tests.
import sbt._
import Keys._
object B extends Build
{
lazy val root =
Project("root", file("."))
.configs( IntegrationTest )
.settings( Defaults.itSettings : _*)
.settings( libraryDependencies += specs )
lazy val specs = "org.scala-tools.testing" %% "specs" % "1.6.8" % "it"
}
这篇关于在 SBT 中为多个测试文件夹设置操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!