Let us say that methodB is a call to an external service (preferable returning a Future, but that is irrelevant for the question). That external service is not valid in some test environments and therefore you want to stub it. Valid use case.
There are several ways to solve that. For example: 1) break out methodB into a class and a test implementation of that can be injected in the constructor of ActorUnderTest 2) create a subclass of ActorUnderTest and override methodB with the test behavior What am I missing? Regards, Patrik On Thu, Jan 8, 2015 at 12:27 AM, <apiw...@gmail.com> wrote: > The issue of testing business functionality that may be implemented in the > class extending Actor has been raised quite a few times and I haven't found > any good suggestions yet. Most Actor testing examples are focused around > message receipt, type, timing etc. Akka team's response to this post > https://groups.google.com/forum/#!topic/akka-user/tWAvAMMcOYs seems to be > very dismissive. Why? This is legitimate issue! If there is no good way to > test functionality provided by classes extending Actors then perhaps it > should be stated please delegate such functionality to services etc. > > What is wrong with example 1, and if nothing, how it is different from > example 2 where I want to stub methodB()? > > Example 1 from https://code.google.com/p/specs/wiki/UsingMockito > object spec extends Specification with Mockito { > > val m = mock[java.util.List[String]] // a concrete class would be > mocked with: mock(new java.util.LinkedList[String]) > > // stub a method call with a return value > m.get(0) returns "one" > > ... > } > > Example 2 > > class ActorUnderTest extends Actor { > def receive = { > case TestMessage => methodA() > } > > def methodA() = { > methodB() > //doSomtehing > } > > def methodB() = { > .... > } > > } > > Andre Piwoni > > -- > >>>>>>>>>> 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 http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Patrik Nordwall Typesafe <http://typesafe.com/> - Reactive apps on the JVM Twitter: @patriknw -- >>>>>>>>>> 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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.