Kity Cartman
Kity Cartman

Reputation: 896

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

Upvotes: 1

Views: 1068

Answers (3)

Radu Ciobanu
Radu Ciobanu

Reputation: 748

You need to use org.scalatest.flatspec.FixtureFlatSpecLike

import org.scalatest.flatspec.FixtureFlatSpecLike

class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec")) 
      with ImplicitSender with FixtureFlatSpecLike with Matchers with BeforeAndAfterAll { ...

Upvotes: 1

Kity Cartman
Kity Cartman

Reputation: 896

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.

Upvotes: 1

ka4eli
ka4eli

Reputation: 5424

Just remove your import. OneArgTest is an inner protected trait in Suite trait, so it can be used in descendants of Suite without import. This should work:

class PingPongActorSpec extends TestKit(ActorSystem("PingPongActorSpec")) 
  with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll {

  override def withFixture(test: OneArgTest) = {}
}

Upvotes: 0

Related Questions