我有下面的ms Scala测试设置,其中我有一个看起来像这样的trait:
trait CPODBTestContainerSpec extends AnyFlatSpecLike with TestContainerForAll {
....
....
}
abstract class BaseCPOControllerSpec extends PlaySpec with Results with FakeApplicationFactory with CPODBTestContainerSpec {
....
....
}
字符串
当我尝试运行它时,我得到以下错误消息。我清楚地了解它的状态,但我不确定我如何解决这个问题。这两个trait做不同的事情,我需要在我的范围内使用它们。
class BaseCPOControllerSpec inherits conflicting members:
protected def info: org.scalatest.Informer (defined in trait AnyWordSpecLike) and
protected def info: org.scalatest.Informer (defined in trait AnyFlatSpecLike)
(note: this can be resolved by declaring an `override` in class BaseCPOControllerSpec.);
other members with override errors are: note, alert, markup, registerTest, registerIgnoredTest, it, they, behave, styleName
abstract class BaseCPOControllerSpec extends PlaySpec with Results with FakeApplicationFactory with CPODBTestContainerSpec {
型
我学习了特质线性化,但不确定我是否可以通过重组我的特质来解决这个问题?
1条答案
按热度按时间eqzww0vc1#
冲突来自于你想要使用的traits的层次结构是混合的:
AnyFlatSpecLike
来自您自己的CPODBTestContainerSpec
AnyWordSpecLike
从PlaySpec
这是用Scalatest编写测试的两种不同方法,两者都用是没有意义的。
如果您需要
PlaySpec
,我会将CPODBTestContainerSpec
更改为extendsAnyWordSpecLike
。