ScalaTest 2.0 doesn't automatically run classes that extend Suite but have been annotated with DoNotDiscover. However, it "will run classes annotated with DoNotDiscover if asked to explicitly, it just won't discover them."
But how do I explicitly ask ScalaTest to run such a DoNotDiscover annotated class?
ScalaTest ignores all such classes although I specify them explicitly via test-only. Example: I have this test suite:
@DoNotDiscover
class AnonLoginSpecRunner
extends org.scalatest.Suites(new AnonLoginSpec)
with StartServerAndChromeDriverFactory
But when I do this:
[my-project] $ test-only test.e2e.specs.AnonLoginSpecRunner
ScalaTest says:
[info] No tests to run for securesocial/test:test-only
[info] Passed: : Total 0, Failed 0, Errors 0, Passed 0, Skipped 0
What can I do to get ScalaTest to run my AnonLoginSpecRunner?
As a work around, I currently do this:
[debiki-server] $ test:console
scala> (new test.e2e.specs.AnonLoginSpecRunner).execute()
and that works, but it's a bit cumbersome and I'd like to avoid it.
(The reason I'm using @DoNotDiscover is I have a main suite that sets up the chrome driver once and for all, and then runs a list of all E2E test specifications.)
The solution I came up with was to create a shell script that ran the test through ScalaTest's "Runner", through SBT
so a simple ./sbtTestFoo.sh script looks something like:
sbt "test:run-main org.scalatest.tools.Runner -o -s
com.foo.TestFoo"
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