Reputation: 11686
I'm integration testing a Play Framework app using ScalaTest. This:
org.scalatest.Suites(list-of-specifications)
executes each test in the list-of-specifications. But how can I avoid each specification being executed independently as well? They're being executed twice.
An example:
import org.scalatest.{Suites, FreeSpec}
class BrowserSuiteSpec extends Suites(new AnonLoginSpec)
class AnonLoginSpec extends FreeSpec { ... }
Now my AnonLoginSpec
is executed twice – first as part of the BrowserSuiteSpec, then independently, since it's a FreeSpec class. (Changing AnonLoginSpec
to a trait results in a compilation errror.)
Renaming AnonLoginSpec
to AnonLoginSpeX
didn't have any effect — it's still being executed twice.
(I thought perhaps ScalaTest was looking for the "Spec" suffix, which I think Specs2 does.)
The documentation doesn't mention this issue (as far as I can tell).
Upvotes: 5
Views: 1038
Reputation: 11686
If you're using pre 2.0-M5, then you can simply declare the spec abstract
and then ScalaTest ignores it. So I did this: (and it works; the test is only run from within the Suites
construct)
class BrowserSuiteSpec extends Suites(new AnonLoginSpec {})
abstract class AnonLoginSpec extends FreeSpec { ... }
(I accepted mpilquist's answer anyway (see above) because that's how things are supposed to work in version 2.0.)
Upvotes: 2
Reputation: 3855
If you are using ScalaTest 2.0.M5 or later, you can annotate each suite with @DoNotDiscover. Alternatively, you can bypass discovery and just specify the main suite class name by passing -s MainSuite to the ScalaTest runner.
Upvotes: 7