import org.scalatest.fixture.Suite.OneArgTest
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll {
override def withFixture(test: OneArgTest) = {}
}
当我尝试使用类型' OneArgTest'的测试覆盖withFixture方法时编译器给我以下错误消息:
答案 0 :(得分:1)
您需要使用 org.scalatest.flatspec.FixtureFlatSpecLike
import org.scalatest.flatspec.FixtureFlatSpecLike
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with FixtureFlatSpecLike with Matchers with BeforeAndAfterAll { ...
答案 1 :(得分:0)
只需删除您的导入。 OneArgTest
是Suite
特征中的内部受保护特征,因此可以在套件的后代中使用而无需导入。这个
应该工作:
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll {
override def withFixture(test: OneArgTest) = {}
}
答案 2 :(得分:0)
而不是混合特性“ FlatSpecLike ”:
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll {
override def withFixture(test: OneArgTest) = {}
}
我们需要混合特质“ fixture.FlatSpecLike ”:
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with fixture.FlatSpecLike with Matchers with BeforeAndAfterAll
override def withFixture(test: OneArgTest) = {}
}
这解决了这个问题。