Sorry, got your question a little wrong at first, so here is my approach.
Create a wrapper actor, that logs the messages:
class LoggingActor(fac: => Actor) extends Actor {
val underlying = context.system.actorOf(Props(fac))
def receive = {
LoggingReceive {
case x ⇒ underlying.tell(x, sender)
}
}
}
and then just create your TestActorRef
with your actor wrapped in the LoggingActor
:
val echo = TestActorRef(new LoggingActor(new FooActor))
echo ! "hello world"