I am currently working on maven based scala project with a bunch of specs2 specification tests and am using Intellij 2020.2 and scala 2.12.10 with specs2 version 4.9.4
I am able to run each specification with no issues but am having issues running all tests sequentially using IntelliJ with beforeAll and afterAll not appearing to work as expected (but does work when run individually).
I was thinking of create a parent specification which creates a list of all children specifications and then executes them - hoping that way I have more control.
My 'children' specifications are using mutable.Specification and along the lines of:
class BookmarkSpecs2(implicit ec: ExecutionEnv) extends Specification
with BeforeAfterAll
with Matchers
with FutureMatchers
with EmbedMongod {
val prefix = "mongodb"
val database = "bcTest"
val domain = "localhost"
val port = 12340
sequential
"Update items" should {
"adding" in {
...
}
}
Note inclusion of class's variable (implicit ec: ExecutionEnv)
For my parent specification I have been trying:
import org.specs2.Specification
import org.specs2.concurrent.ExecutionEnv
import org.specs2.specification.core.SpecStructure
class AllTestsSpecs2(implicit ec: ExecutionEnv) extends Specification {
def is: SpecStructure = sequential ^ s2"""
${"bookmark" ~ bm}
"""
def bm = new BookmarkSpecs2()
}
When executing the specification via IntelliJ it shows:
Testing started at 10:36 AM ...
/opt/jdk/jdk8u265-b01/bin/java -javaagent:/home/colinbester/Projects/idea-IC-202.6397.94/lib/idea_rt.jar=46535:/home/colinbester/Projects/idea-IC-202.6397.94/bin -Dfile.encoding=UTF-8 -classpath ... org.jetbrains.plugins.scala.testingSupport.specs2.Specs2Runner -s com.besterdesigns.bc.rest.AllTestsSpecs2 -showProgressMessages true
Process finished with exit code 0
without actually running any of the children test.
Pretty sure I am missing something here and would appreciate nudge in right direction.
Linked specifications can be executed by passing the all
argument (the list of available arguments is available here).
In IntelliJ specs2 properties need to be specified as Java system properties so you need to specify -Dspecs2.all
in the IntelliJ run configuration.