Setting up actions for multiple test folders in SBT

痞子三分冷 提交于 2019-12-22 04:27:13

问题


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.

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?


回答1:


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"
}


来源:https://stackoverflow.com/questions/6224273/setting-up-actions-for-multiple-test-folders-in-sbt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!