如何在scala中运行带有word规范的before方法? 我有这个代码,但是在我的测试之前没有执行before方法:
class SomeClassTest extends TestKit(ActorSystem("test", ConfigFactory.empty())) with WordSpecLike with MockitoSugar with BeforeAndAfter {
override protected def before(fun: => Any): Unit = {
//some code ...
}
"A SomeClass" must {
"blah blah blah" in {
//some code...
}
}
}
答案 0 :(得分:0)
您实际上不必在before
中覆盖SomeClassTest
,而是通过带有测试设置代码的函数来调用它:
class SomeClassTest extends TestKit(ActorSystem("test", ConfigFactory.empty())) with WordSpecLike with MockitoSugar with BeforeAndAfter {
before {
//some code ...
}
"A SomeClass" must {
"blah blah blah" in {
//some code...
}
}
}