问题
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
I want to run this doing something like
sbt test-unit // or something like that
I also want to do the same by excluding tests
sbt test-only -- -l ExternalTests
to:
sbt test-exclude-external
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)
}
It will be useful if also I can run tests by namespace in a custom sbt task:
sbt testOnly integration.actors.*
Can you help me guys? I'm a little newbie with sbt :(
回答1:
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
}
回答2:
You should be able to use fullInput
as in this SO question.
Also, possible duplicate of this.
来源:https://stackoverflow.com/questions/35863430/custom-sbt-task-to-run-tests-by-tag