【发布时间】:2012-04-19 20:19:53
【问题描述】:
如何在包装函数中执行 spec2 规范的所有测试?
例如:
class HelloWorldSpec extends Specification {
wrapAll(example) = {
// wrap it in a session, for example.
with(someSession){
example()
}
}
"The 'Hello world' string" should {
"contain 11 characters" in {
"Hello world" must have size(11)
}
"start with 'Hello'" in {
"Hello world" must startWith("Hello")
}
"end with 'world'" in {
"Hello world" must endWith("world")
}
}
}
所以,这 3 个测试中的每一个都应该在
with(someSession){...
使用 ScalaTest 时,我可以覆盖 withFixture
【问题讨论】:
标签: unit-testing scala specs2