I am a step further in compiling my tests, but now running it yields in another error:
----------------------------------------------------------------------- -------- Test set: zzz.akka.avionics.EventSourceSpec --------------------------------------------- ---------------------------------- Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.001 sec <<< FAILURE! initializationError(zzz.akka.avionics.EventSourceSpec) Time elapsed: 0.007 sec <<< ERROR! java.lang.NoSuchMethodError: scala.Predef$ArrowAssoc$.extension$$minus$greater(Ljava/lang/Object;Ljava/lang/ Object;)Lscala/Tuple2; at org.scalatest.SuperEngine.registerTest(Engine.scala:463) at org.scalatest.WordSpec$class.org$scalatest$WordSpec$$registerTestToRun(WordSpec .scala:1646) at org.scalatest.WordSpec$WordSpecStringWrapper.in(WordSpec.scala:1783) at zzz.akka.avionics.EventSourceSpec$$anonfun$1.apply$mcV$sp(EventSourceSpec.scala :22) at zzz.akka.avionics.EventSourceSpec$$anonfun$1.apply(EventSourceSpec.scala:22) at zzz.akka.avionics.EventSourceSpec$$anonfun$1.apply(EventSourceSpec.scala:22) at org.scalatest.SuperEngine.registerNestedBranch(Engine.scala:411) at org.scalatest.WordSpec$class.org$scalatest$WordSpec$$registerBranch(WordSpec.sc ala:1673) at org.scalatest.WordSpec$$anon$1.apply(WordSpec.scala:2113) at org.scalatest.verb.ShouldVerb$StringShouldWrapperForVerb.should(ShouldVerb.scal a:189)
...
Google suggests that I still have Scala 2.9.x dependencies in my classpath, but I am fairly sure I haven't.
I have configured a JUnitRunner to execute my test with Surefire (as I have done in other, non-Akka related Scala projects)
@RunWith(classOf[JUnitRunner]) class EventSourceSpec extends TestKit(ActorSystem("EventSourceSpec")) with WordSpec with MustMatchers with BeforeAndAfterAll {
"allow us to register a listener" in { val real = TestActorRef[MyEventSource].underlyingActor real.receive(RegisterListener(testActor)) real.listeners must contain (testActor) }
}
For completeness, this is my current classpath reported from Maven:
[INFO] The following files have been resolved: [INFO] com.typesafe:config:jar:1.0.0:compile [INFO] com.typesafe.akka:akka-actor_2.10.0-RC2:jar:2.1.0-RC2:compile [INFO] com.typesafe.akka:akka-testkit_2.10.0-RC2:jar:2.2-SNAPSHOT:test [INFO] junit:junit:jar:4.9:compile [INFO] org.hamcrest:hamcrest-core:jar:1.1:compile [INFO] org.scala-lang:scala-actors:jar:2.10.0-RC2:compile [INFO] org.scala-lang:scala-actors-migration_2.10.0-RC2:jar:1.0.0-RC2:compile [INFO] org.scala-lang:scala-library:jar:2.10.0-RC2:compile [INFO] org.scala-lang:scala-library-all:pom:2.10.0-RC2:compile [INFO] org.scala-lang:scala-reflect:jar:2.10.0-RC2:compile [INFO] org.scala-lang:scala-swing:jar:2.10.0-RC2:compile [INFO] org.scalatest:scalatest_2.10.0-M4:jar:1.9-2.10.0-M4-B1:test
It does look like there's some interesting classpath stuff going on, and I don't think you've actually pasted the classpath. As far as I recall, the best way to get it is "mvn dependency:build-classpath".
You are right, I didn't paste the classpath, but the output from the dependency:build-classpath ;)
However,
Changing the test to
@RunWith(classOf[JUnit4]) class EventSourceSpec extends TestKit(ActorSystem("EventSourceSpec")) with WordSpec with MustMatchers with BeforeAndAfterAll {
"allow us to register a listener" in { val actor = TestActorRef[MyEventSource](Props[MyEventSource]) val real = actor.underlyingActor real.receive(RegisterListener(testActor)) real.listeners must contain (testActor) }