Search code examples
scalaakkaactor

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) = {}
}

When I am trying to override withFixture method with test of type 'OneArgTest' the compiler is giving me following error messages:

  1. object Suite is not a member of package org.scalatest.fixture Note: trait Suite exists, but it has no companion object.
  2. not found: type OneArgTest

Solution

  • Instead of mixing in trait "FlatSpecLike":

    class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec")) 
      with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll  {
      override def withFixture(test: OneArgTest) = {}
    }
    

    We need to mix trait "fixture.FlatSpecLike":

    class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec")) 
      with ImplicitSender with fixture.FlatSpecLike with Matchers with BeforeAndAfterAll
      override def withFixture(test: OneArgTest) = {}
    }
    

    This resolve the issue.