It's pretty clear that one would like to pass a single test as an argument to test-only, so that you can do what it's documentation says: run one test.
But how do you do this? In java, you probably have a class UserTest that extends WithApplication and defines a bunch of tests on the User model (using @Test for each).
You would like to say
test-only models.UserTest.createAUser
but test-only will tell you
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] No tests to run for test:testOnly
[success] Total time: 0 s
So how do you run only one test?
Yes, SBT only supports class name granularity. The reason for this is that most of the test frameworks SBT supports don't use one method per test, they use DSLs for tests, eg specs2 tests look like this:
"The plus sign" should {
"add two numbers" in {
2 + 3 === 5
}
"be communatative" in {
1 + 2 === 2 + 1
}
}
And in fact these specs can be nested arbitrarily deep, they can have the same names as each other, they can be parameterized and reused arbitrarily, etc, to the point where specifying a single test and understanding what that should do from the command line doesn't make sense. So SBT has just provided support for what makes sense in all test frameworks, and that's class name granularity.
I found "an" answer which isn't what I was expecting.
You can say
test-only models.UserTest
and it will "work" ... that is to say, it will run "only" all those tests in UserTest (thus not running every other test class, which is somewhat helpful).
But it appears you can't do
test-only models.UserTest.createAUser
to test just that one test.
Huh!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With