Yup, I'm using the in-mem journal and the FS-based snapshots for my test - deleting them in my code that makes it use a new TestKit fixture for each test has worked out just great. The tests are fairly quick even creating a whole new TestKit every time so seems I've got my problems solved.
Thanks all On Fri, Apr 15, 2016 at 11:25 PM Patrik Nordwall <[email protected]> wrote: > With persistence you need to clean the data, eg remove files if you use > leveldb for testing. We have plenty of tests in the akka code base that > does that. There is also community maintained in-mem journal for testing. > See http://akka.io/community/ > > /Patrik > fre 15 apr. 2016 kl. 23:16 skrev Spencer Judge <[email protected]>: > >> Thanks Johan, >> >> That makes sense. I think when I'm not testing persistence it'll be no >> issue for me to keep the same actor system around. While testing >> persistence, however, it seems like a good idea to start fresh each time. I >> suppose if I keep using different actor names each time it'd probably work >> out just fine still, but it gives me peace of mind to start fresh. >> >> Thanks again! >> >> Spencer >> >> >> On Friday, April 15, 2016 at 11:08:30 AM UTC-7, Johan Andrén wrote: >>> >>> Hi Spencer, >>> >>> ActorSystems are semi-expensive, starting the dispatcher thread pool >>> etc. on startup so this is the rationale for sharing one throughout the >>> test. TestKit is built around this and will require a single actor system >>> throughout the test. As there are no ties to any specific testing framework >>> in the akka testkit there isn't anything shipped with it that hooks up >>> before-and-after style hooks - those would be test framework specific. Most >>> of the tools that make up testkit is however not dependent on TestKit but >>> can be used stand-alone. Starting your actor system is one line of code, >>> and shutting it down is one line (TestKit.shutdownActorSystem(system)) so >>> hooking it into any test framework should not be much work. >>> For ScalaTest you can read about using BeforeAndAfter here: >>> http://www.scalatest.org/user_guide/sharing_fixtures#beforeAndAfter >>> especially the "Calling loan fixture-fixture methods" section where the >>> ActorSystem would be what you loan into each test case. >>> >>> In general if you keep your actors loose coupled and keep them from >>> knowing about the absolute paths to other actors tests will be isolated >>> enough even if they share actor system that they can even run >>> simultaneously. Some times you need isolation though, I wouldn't say that >>> in itself is a smell. If no single actor in your entire app can be tested >>> without being isolated it may be something to think twice about though. >>> >>> I hope this helps! >>> -- >>> Johan Andrén >>> Akka Team, Lightbend Inc. >>> >>> On Thursday, April 14, 2016 at 9:06:21 PM UTC+2, Spencer Judge wrote: >>>> >>>> I started writing some tests using the TestKit, and it's quite nice - >>>> but I quickly realized the ActorSystem persists between tests. This seems a >>>> bit odd to me, since it introduces potential coupling between the order of >>>> test execution and their results. It doesn't feel like what I would expect >>>> the default behavior to be. >>>> >>>> Is there a particular reason for this? Is the fact that I want to reset >>>> my system between each test a smell? I want to do this in my particular >>>> test class because I am testing persistence. >>>> >>>> Lastly, is there an easy way to change the behavior? >>>> I found this old thread: >>>> https://groups.google.com/forum/embed/#!topic/akka-user/-Cvf9K5P0a0 >>>> >>>> Which has a solution, albeit a somewhat complicated one. It seems like >>>> this would be a very good thing to be able to do simply, without needing to >>>> create and destroy a new ActorSystem for every test manually (ex: have a >>>> "reset system" method I can call in test teardown). I'm wondering if >>>> there's an easier way to do it today. >>>> >>>> Thank you! >>>> Spencer >>>> >>> -- >> >>>>>>>>>> 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 https://groups.google.com/group/akka-user. >> For more options, visit 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 a topic in the > Google Groups "Akka User List" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/akka-user/z813tWbUL2c/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
