We like to isolate side effects (DB, S3 stuff, etc) in their own actors and include them in the constructor of the actor doing the actual work. Then we can just use TestProbes when we construct the worker actor in unit tests.
In our integration tests, we use concrete actors for everything and let them actually hit S3 and a MySQL instance on our CI server. On Wednesday, April 23, 2014 9:52:34 AM UTC-6, Edward Sargisson wrote: > > Hi, > Forgive me if this particular case has been asked and answered many times > already but my google skills are failing me. > > I would like to unit test an actor that gets an image from Amazon S3, > extracts some metadata and writes it to the database with Slick. I > understand how to use Akka TestKit to mock and verify the message sending > but that's not the issue; I want to verify what the actor is actually doing. > > My initial approach was to put the database code into a separate class and > attempt to inject a mock for that close into the actor. However, scalatest, > scalamock and Akka TestKit appear to conflict and not allow me to define > the class (I'm not at my dev machine but the error was something about > withFixture being overridden with the wrong access). > I also attempted this using my (very flawed) understanding of the Cake > pattern and got tied up in how I might use the companion object with it. > > So what's the idiomatic way of doing this? Do I try and put each > side-effect piece (S3, database, etc.) into a separate actor and use Akka > TestKit to verify the flows and unit test the side-effects without mocks? > Or is there a nice example out there I can follow? > > Many thanks, > Edward > -- >>>>>>>>>> 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.
