Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell ScalaTest to run a class annotated with DoNotDiscover?

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.)

like image 791
KajMagnus Avatar asked Jan 24 '14 02:01

KajMagnus


1 Answers

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"
like image 167
ericpeters Avatar answered Sep 21 '22 14:09

ericpeters