Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How avoid executing ScalaTest specification twice, when it's part of a `Suites`

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

like image 986
KajMagnus Avatar asked Jan 14 '23 15:01

KajMagnus


1 Answers

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.

like image 74
mpilquist Avatar answered Jan 30 '23 00:01

mpilquist