无法覆盖 withFixture(测试:OneArgTest)
Unable to override withFixture(test: OneArgTest)
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 方法时,编译器给我以下错误消息:
- object Suite 不是包的成员 org.scalatest.fixture 注意:trait Suite 存在,但它没有伴随对象。
- 未找到:键入 OneArgTest
只需删除您的导入。 OneArgTest
是 Suite
特性中的内部保护特性,因此它可以在 Suite 的后代中使用而无需导入。这个
应该工作:
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll {
override def withFixture(test: OneArgTest) = {}
}
而不是混合特征“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) = {}
}
这解决了问题。
您需要使用org.scalatest.flatspec.FixtureFlatSpecLike
import org.scalatest.flatspec.FixtureFlatSpecLike
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with FixtureFlatSpecLike with Matchers with BeforeAndAfterAll { ...
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 方法时,编译器给我以下错误消息:
- object Suite 不是包的成员 org.scalatest.fixture 注意:trait Suite 存在,但它没有伴随对象。
- 未找到:键入 OneArgTest
只需删除您的导入。 OneArgTest
是 Suite
特性中的内部保护特性,因此它可以在 Suite 的后代中使用而无需导入。这个
应该工作:
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll {
override def withFixture(test: OneArgTest) = {}
}
而不是混合特征“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) = {}
}
这解决了问题。
您需要使用org.scalatest.flatspec.FixtureFlatSpecLike
import org.scalatest.flatspec.FixtureFlatSpecLike
class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec"))
with ImplicitSender with FixtureFlatSpecLike with Matchers with BeforeAndAfterAll { ...