使用akka actor的Scala简单funsuite单元测试失败



嘿,我想为一个演员应用程序构建一些小的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())
  }
}

intelligent idea测试环境说:

One or more requested classes are not Suites: model.ActorSynchroTest
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"
}
               """
}

在使用不适合

的标准配置之前,testkit的不同初始化最终工作

相关内容

  • 没有找到相关文章

最新更新