有时我们需要在测试用例中混入一些特征。但是以下方法不起作用:
"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。有更好的方法吗?