i am using akka testkit and scalatests for running my test here is my code
class MyTest extends (ActorSystem("testsystem")) /*with AsyncWordSpec*/ with ImplicitSender with AnyWordSpecLike with Matchers with BeforeAndAfterAll {
"an actor test" must {
val probe = TestProbe()
val myActor1 = TestActorRef[MyActor]
"send back messages " in {
probe.send(myActor1,Found(id = "234"))
probe.expectMsg(true)
//i want to get the future value like this as well
val future = ask(myActor, Found(id = "234")).mapTo[Boolean]
future onComplete {
case Success(somevalue) => info("oncomplete returned result is " + somevalue)
case Failure(ex) =>throw ex
}
}
}
class MyActor extends Actor {
def receive: PartialFunction[Any, Unit] = {
case Found(id) =>
log.info("received message {}", id)
sender() ! true
case message =>
unhandled(message)
}
}
now the problem is the above code works fine but the future on complete part is sometime executed and sometimes its not when running the test for that i researched about async testing scala and try to implement the examples http://www.scalatest.org/user_guide/async_testing
for that i need to extend from any of the given classes there i chose AsyncWordSpec
so that i can run the async tests and get the value of future every time but i am already extending from TestKit
class i can not extend from the abstract class AsyncWordSpec
so how can i get this to work?