自定义 sbt 任务按标签运行测试 [英] Custom sbt task to run tests by tag

查看:54
本文介绍了自定义 sbt 任务按标签运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为按标签运行测试(scalatest)做一些 sbt 自定义任务.例如:现在我可以在 sbt 控制台中运行它:

I want to do some sbt custom tasks for running tests (scalatest) by tag. For example: now I can run this in the sbt console:

sbt test-only -- -n UnitTests

我想像

sbt test-unit // or something like that

我也想通过排除测试来做同样的事情

I also want to do the same by excluding tests

sbt test-only -- -l ExternalTests

sbt test-only -- -l ExternalTests

到:

sbt test-exclude-external

为了实现这一点,我正在尝试创建一个自定义 sbt 任务......但我不知道如何做 ---l 的东西

For accomplishing that I'm trying to create a custom sbt task... but i don't know how to do the -- -l stuff

val testUnit = taskKey[Unit]("Launch unit tests")
testUnit := {
  // sbt test-only -- -n UnitTests
  //(test in Test)
}

如果我也可以在自定义 sbt 任务中按命名空间运行测试,那将会很有用:

It will be useful if also I can run tests by namespace in a custom sbt task:

sbt testOnly integration.actors.*

你们能帮我吗?我是 sbt 的小新手 :(

Can you help me guys? I'm a little newbie with sbt :(

推荐答案

fullInput 不适用于in Test".我终于做到了:

fullInput does not work well with "in Test". I've finally did this:

val unit = taskKey[Unit]("Launch unit tests")
unit := {
  (testOnly in Test).toTask(s" com.trololo.unit.*").value
}

这篇关于自定义 sbt 任务按标签运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆