使用范围执行规范不会调用子测试
Executing Specification with Scope does not call sub tests
给定以下规格
class Config2Spec extends org.specs2.mutable.Specification {
"reading different versions of config should work" in new aScope {
"buffer should contain a proper config" in {
buffer(0).content should have size 1
}
"buffer should have fresh config" in {
buffer should have size 2
buffer(1).content should have size 2
}
}
trait aScope extends Scope {
val buffer : mutable.Buffer[Config] = mutable.Buffer()
val cfg1 = "l1"
val cfg2 = "l1\nl2"
val file = "testCfg"
val path = Paths.get(System.getProperty("user.home"), "test")
Files.createDirectories(path)
val of = ObservableFile(path, file)
Files.write(of.asPath, cfg1.getBytes("UTF-8"))
buffer += ConfigReader.read(file, {cfg => buffer += cfg})
Files.write(of.asPath, cfg2.getBytes("UTF-8"))
Thread.sleep(1000)
}
}
两个示例 "buffer should contain a proper config" 和 "buffer should have fresh config" 永远不会被调用。必须更改什么才能使其正常工作?
范围只能用于 "terminal" 个示例:
class Config2Spec extends org.specs2.mutable.Specification {
"reading different versions of config should work" in {
"buffer should contain a proper config" in new aScope {
i === 0
i += 1
}
"buffer should have fresh config" in new aScope {
i === 0
i += 1
}
}
trait aScope extends Scope {
var i = 0
}
}
给定以下规格
class Config2Spec extends org.specs2.mutable.Specification {
"reading different versions of config should work" in new aScope {
"buffer should contain a proper config" in {
buffer(0).content should have size 1
}
"buffer should have fresh config" in {
buffer should have size 2
buffer(1).content should have size 2
}
}
trait aScope extends Scope {
val buffer : mutable.Buffer[Config] = mutable.Buffer()
val cfg1 = "l1"
val cfg2 = "l1\nl2"
val file = "testCfg"
val path = Paths.get(System.getProperty("user.home"), "test")
Files.createDirectories(path)
val of = ObservableFile(path, file)
Files.write(of.asPath, cfg1.getBytes("UTF-8"))
buffer += ConfigReader.read(file, {cfg => buffer += cfg})
Files.write(of.asPath, cfg2.getBytes("UTF-8"))
Thread.sleep(1000)
}
}
两个示例 "buffer should contain a proper config" 和 "buffer should have fresh config" 永远不会被调用。必须更改什么才能使其正常工作?
范围只能用于 "terminal" 个示例:
class Config2Spec extends org.specs2.mutable.Specification {
"reading different versions of config should work" in {
"buffer should contain a proper config" in new aScope {
i === 0
i += 1
}
"buffer should have fresh config" in new aScope {
i === 0
i += 1
}
}
trait aScope extends Scope {
var i = 0
}
}