我有以下测试用例:
class MutableStateActorTest extends TestKit(ActorSystem("MutableStateActorTest")) with WordSpecLike with Matchers {
"A MutableStateActor" must {
val actRef = TestActorRef[MutableStateActor]
"mutate state in order" in {
1 to 5 foreach {
x => actRef ! Increment
}
}
}
}
这不可能更简单,但是当我尝试运行它时出现以下错误:
An exception or error caused a run to abort: Found class akka.actor.ActorPath, but interface was expected
java.lang.IncompatibleClassChangeError: Found class akka.actor.ActorPath, but interface was expected
at akka.testkit.TestActorRef.<init>(TestActorRef.scala:47)
at akka.testkit.TestActorRef$.apply(TestActorRef.scala:141)
at akka.testkit.TestActorRef$.apply(TestActorRef.scala:137)
at akka.testkit.TestActorRef$.apply(TestActorRef.scala:146)
at akka.testkit.TestActorRef$.apply(TestActorRef.scala:144)
at q31.sandbox.statetest.MutableStateActorTest$$anonfun$1.apply$mcV$sp(MutableStateActorTest.scala:16)
at q31.sandbox.statetest.MutableStateActorTest$$anonfun$1.apply(MutableStateActorTest.scala:14)
at q31.sandbox.statetest.MutableStateActorTest$$anonfun$1.apply(MutableStateActorTest.scala:14)
我想这与Actor References有关?
答案 0 :(得分:3)
您可能正在针对akka的快照版本运行。在akka 2.4的最新版本中,有些内容在ActorRef
方面有所改变,或者更好地说ActorPath
。您正在使用的库是针对较旧版本的akka编译的,因此期望ActorPath
是一个接口,而不是它在较新版本中的类。
冲突的变化似乎是这样的: https://github.com/akka/akka/commit/e6aea0b7d1bab7668072e1d92945ebb1865bdd9a
在此更改中(以下更改了以下内容:
-sealed trait ActorPath extends Comparable[ActorPath] with Serializable {
+sealed abstract class ActorPath extends Comparable[ActorPath] with Serializable {
要解决此问题,请从您自己项目中可能使用的快照移开,或者从您投放错误的项目中重新编译代码,而不是使用您正在使用的akka(快照)版本自己。