I have the following setup for ms Scala test where I have a trait that looks like this:
trait CPODBTestContainerSpec extends AnyFlatSpecLike with TestContainerForAll {
....
....
}
abstract class BaseCPOControllerSpec extends PlaySpec with Results with FakeApplicationFactory with CPODBTestContainerSpec {
....
....
}
When I tried to run it, I get the following error message. I clearly understand what it states, but I'm not sure how I could fix this. These two traits above do different things and I need both of them in my scope.
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 {
I learnt about trait linearization, but not sure if I can fix this by restructuring my traits?
The conflict comes from the fact that the hierarchy of traits you want to use is mixing:
AnyFlatSpecLikefrom your ownCPODBTestContainerSpecAnyWordSpecLikefromPlaySpecThese are two different ways of writing tests with Scalatest. It doesn't make sense to want to use both.
If you need the
PlaySpec, I would changeCPODBTestContainerSpecto extendsAnyWordSpecLike.