Yes, indeed, thanks for sharing! It would be awesome if you could add this to 
the docs, if you don’t mind.

Regards,

Roland

> 23 mar 2016 kl. 10:17 skrev Sven Hodapp <sven.hod...@gmail.com>:
> 
> I've found a solution:
> 
>       EventFilter.info(pattern="log content", occurrences=1) intercept {
>         ac ! Consume(...)
>       }
> 
> Regards,
> Sven 
> 
> Am Dienstag, 22. März 2016 09:13:13 UTC+1 schrieb Sven Hodapp:
> Dear reader,
> 
> I've seen in the documentation that it is possible to do assertions on Akka 
> log messages.
> 
> http://doc.akka.io/docs/akka/current/scala/testing.html#Expecting_Log_Messages
>  
> <http://doc.akka.io/docs/akka/current/scala/testing.html#Expecting_Log_Messages>
> 
> But the documentation is here a bit sparsely and doesn't explain how to do 
> "non-exception" assertions.
> You can give me an hint how to do it?
> 
> My current code looks similar to this:
> 
> class TheActorSpec(_system: ActorSystem)
>   extends TestKit(_system)
>   with ImplicitSender
>   with Matchers
>   with FlatSpecLike
>   with BeforeAndAfterAll {
> 
>   def this() = this(ActorSystem("testsystem", ConfigFactory.parseString("""
>   akka.loggers = ["akka.testkit.TestEventListener"]
>   """)))
> 
>   override def afterAll: Unit = {
>     system.shutdown()
>     system.awaitTermination(10.seconds)
>   }
> 
>   "An Actor" should "be able to assert log messages" in {
>     val ac = TestActorRef(Props[TheActor])
> 
>     ac ! Consume(...)
>  
>     // Or with pattern="..."?
>     EventFilter.info(message="the log content", 
> source=classOf[TheActor].getName, occurrences=1).assertDone(1.second)  
> 
>   }
> 
> }
> 
> But I get Stacktraces like "[...] java.lang.AssertionError: assertion failed: 
> 1 messages outstanding on InfoFilter [...]".
> Within TheActor Consume is log.info <http://log.info/>("the log content") 
> called.
> 
> Anybody an idea what's wrong or how to use EventFilter correctly?
> 
> Thanks!
> 
> Regards,
> Sven
> 
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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 akka-user+unsubscr...@googlegroups.com 
> <mailto:akka-user+unsubscr...@googlegroups.com>.
> To post to this group, send email to akka-user@googlegroups.com 
> <mailto:akka-user@googlegroups.com>.
> Visit this group at https://groups.google.com/group/akka-user 
> <https://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to