有时我们需要在测试用例中混合一些特征。但是以下方法不起作用:
"abc" should {
"def" in new TraitA with TraitAB {
// ...
}
}
为了使其有效,我们执行以下操作:
trait Fixture extends Before {
def before = ()
}
"abc" should {
"def" in new Fixture with TraitA with TraitAB {
// ...
}
}
这感觉有点hacky。有没有更好的方法呢?
答案 0 :(得分:2)
如果您还混合了org.specs2.specification.Scope
标记特征:
"abc" should {
"def" in test {
// ...
}
}
trait test extends TraitA with TraitAB with Scope