1
我想編寫一個使用Akka actor並從sbt運行的ScalaTest測試套件。當我嘗試這樣做:Scalatest FunSuite和Akka Actor
class Tests extends FunSuite with BeforeAndAfterAll {
override protected def beforeAll() {
class Actor1 extends Actor {
protected def receive = {
case 1 => println("One")
}
}
val sys = ActorSystem("my")
val a = sys.actorOf(Props[Actor1], "plain_actor")
a ! 1
sys.shutdown()
}
}
,然後sbt test
,我得到
[ERROR] [01/22/2012 12:49:50.329] [default-dispatcher10] [akka://my/user/plain_actor] error while creating actor
但是,當我寫在通常的主類,而不是一個FunSuite相同的代碼,並通過sbt run
運行它,所有的作品。這兩種情況之間有什麼區別,以及我如何讓Akka actor在測試套件中正確運行?