单个spec2s父规范中的specs2规范的运行列表



我目前正在进行基于maven的scala项目,其中包含一系列specs2规范测试,并使用Intellij 2020.2和scala 2.12.10以及specs2 4.9.4 版本

我能够毫无问题地运行每个规范,但在使用IntelliJ顺序运行所有测试时遇到问题,beforeAll和afterAll似乎没有按预期工作(但单独运行时确实工作(。

我想创建一个父规范,创建一个所有子规范的列表,然后执行它们——希望这样我可以有更多的控制权。

我的"children"规范正在使用mutable。规范和沿线:

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 {
...
}
}

注意包含类的变量(implicit ec: ExecutionEnv)

对于我的父规范,我一直在尝试:

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()
}

当通过IntelliJ执行规范时,它显示:

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

而没有实际运行任何儿童测试。

我很确定我在这里错过了什么,希望能朝着正确的方向前进。

可以通过传递all参数来执行链接的规范(此处提供可用参数列表(。

在IntelliJ规范2中,需要将属性指定为Java系统属性,因此需要在IntelliJ运行配置中指定-Dspecs2.all

最新更新