0

嘿,我想为 akka actor 应用程序构建一些小的 Funsuite 测试,但是在将 Testkit 与 FunSuiteLike 结合后,我不能再调用这个测试了。有人知道为什么会这样吗?Testkit 和 funsuite 不兼容吗?

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())
  }
}

intelliJ idea 测试环境说:

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

1 回答 1

1
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"
}
               """
}

在使用不适合的标准配置之前,测试套件的不同初始化最终起作用

于 2014-08-19T20:09:39.737 回答