I'm trying to code some test cases for my actors, the problem is that some tests fail and I can't get a clue of why are they failing.
In a normal scenario my code is working fine (Without any tests), but for my tests I'm mocking some parts of the twitter4j library, which makes them somehow complicated.
The tests are failing and there is no more useful info about it.
Is there a way to log the received message with akka testkit and scalatest?
If you want to be able to log all received messages, there are three things you must do:
Wrap your
receive
function on the actor you want to enable logging for with aLoggingReceive
(from theakka.event
package).Set the
akka.actor.debug.receive
setting from the config totrue
Make sure your logging config will show messages at the
DEBUG
levelSo your actor might look something like this:
If you set things up like that you should start seeing all incoming messages logged to the
DEBUG
level for your actor under test. You can read more on this in the Testing Actor Systems section of the Akka Docs, specifically the Tracing Actor Invocations subsection.