Hi Harit,

as you are passing in Props to the TestActorRef apply method
<https://github.com/akka/akka/blob/8485cd2ebb46d2fba851c41c03e34436e498c005/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala#L134>,
you will have to specify type of your actor because Props do not have a
type parameter:

val runner = TestActorRef[Runner](Props(new Runner(new Marathon)))

Alternatively, you can use a different TestActorRef apply method
<https://github.com/akka/akka/blob/8485cd2ebb46d2fba851c41c03e34436e498c005/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala#L130>
that accepts a code thunk that returns a new instance of your actor:

val runner = TestActorRef(new Runner(new Marathon))

On Mon, Jun 1, 2015 at 7:13 AM, Harit Himanshu <
[email protected]> wrote:

> Hey there,
>
> This is what my actor looks like
>
> object Runner {
>   def props(race: Race) = Props(classOf[Runner], race)}
> class Runner(race: Race) extends Actor with ActorLogging {
>
>   import context.dispatcher
>
>   @throws[Exception](classOf[Exception])
>   override def postRestart(reason: Throwable): Unit = context.parent ! 
> RestartRunner
>
>   override def receive: Receive = LoggingReceive {
>     case Start => {
>       log.debug("running...")
>       for (i <- 1 to 3) {
>         Thread.sleep(200)
>       }
>       throw new RuntimeException("MarathonRunner is tired")
>     }
>
>     case StartWithFuture =>
>       log.debug("I am starting to run")
>       race.start pipeTo self
>
>     case Failure(throwable) => throw throwable
>
>     case Stop =>
>       log.debug("stopping runner")
>       context.stop(self)
>   }}
>
> and this is what my test looks
>
> import akka.actor.{Props, ActorSystem}import akka.testkit.{TestActorRef, 
> TestKit}import org.scalatest._
> class RunnerSpec extends TestKit(ActorSystem("test"))with WordSpecLikewith 
> MustMatchers {
>   "A Runner Actor" must {
>     val runner = TestActorRef(Props(new Runner(new Marathon)))
>     "receive messages" in {
>       runner ! Start
>       runner.under <== says Nothing (see attachment)
>     }
>   }}
>
> So, when I try to get the underlyingActor, I get `Nothing`, what is wrong
> here?
>
>
> <https://lh3.googleusercontent.com/-BtnZjaaSzYQ/VWvb1nsRyjI/AAAAAAAAAGo/9TiyQGPSjm8/s1600/Screen%2BShot%2B2015-05-31%2Bat%2B9.06.59%2BPM.png>
> Thanks a lot
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Martynas Mickevičius
Typesafe <http://typesafe.com/> – Reactive
<http://www.reactivemanifesto.org/> Apps on the JVM

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to