Scala simple funsuite unit test with akka actors fails

913 views Asked by At

Hey i want to build some small Funsuite test for akka actor application but after combining Testkit with FunSuiteLike i cant call th test anymore. Somebody an idea why this is happening? is Testkit and funsuite not compatible?

import org.scalatest.{FunSuiteLike, BeforeAndAfterAll}
import akka.testkit.{ImplicitSender, TestKit, TestActorRef}
import akka.actor.{ActorSystem}

class ActorSynchroTest(_system: ActorSystem) extends TestKit(_system) with FunSuiteLike with BeforeAndAfterAll with ImplicitSender{


  val actorRef =  TestActorRef(new EbTreeDatabase[Int])
  val actor = actorRef.underlyingActor

  //override def afterAll = TestKit.shutdownActorSystem( system )

  test("EbTreeDatabase InsertNewObject is invoked"){
    val idList = List(1024L,1025L,1026L,1032L,1033L,1045L,1312L,1800L)
      idList.
      foreach(x => actorRef ! EbTreeDataObject[Int](x,x,1,None,null))
    var cursor:Long = actor.uIdTree.firstKey()
    var actorItems:List[Long] = List(cursor)

    while(cursor!=actor.uIdTree.lastKey()){
      cursor = actor.uIdTree.next(cursor)
      cursor :: actorItems
    }
    assert(idList.diff(actorItems)  == List())
  }
}

The intelliJ idea test enviroment says:

One or more requested classes are not Suites: model.ActorSynchroTest
1

There are 1 answers

0
prototyp On
class ActorSynchroTest extends TestKit(ActorSystem("ActorSynchroTest",ConfigFactory.parseString(ActorSynchroTest.config)))
with DefaultTimeout with ImplicitSender
with FunSuiteLike with Matchers with BeforeAndAfterAll  {
 ...

}

object ActorSynchroTest {
  // Define your test specific configuration here
  val config = """
akka {
loglevel = "WARNING"
}
               """
}

Different initialization of the testkit worked in the end before the standard config was used which didn't fit