> ok,maybe POSO is not possible. But if I understand correctly, the only 
basic requirement for an actor is an Actor.Receive (a partial function).

Yes, and if you look in the akka.actor.Actor trait, that's the only 
abstract method required by that trait.

> The main "issue" is that actors extends Actor (which is nice and proper 
in terms of class hierarchy) with actor containing fields context, self, 
sender() etc. That's nice and convenient but it creates a few testability 
issues. i.e.

They mix in the trait, rather than extending a subclass.

Your example doesn't demonstrate any problem with subclasses v.s. POSOs.
If I change the example code to be a POSO, there is still the exact same 
problem:

class MyParentPoso {
    private val child = new ChildPoso()
...
    child.say("hi") // how to test the communication 
between MyParentPoso and child?
}

Your example is one where Dependency Injection (rather than having the 
parent create its own collaborator) will lead to testable code:

class MyActor(collaborator: ActorRef) extends Actor {
   ...

   collaborator ! "hi" // now you can test the communication
}


Hope this helps,


Rich



On Tuesday, June 16, 2015 at 2:57:05 PM UTC+1, Kostas kougios wrote:
>
>  ok,maybe POSO is not possible. But if I understand correctly, the only 
> basic requirement for an actor is an Actor.Receive (a partial function).
>
> The main "issue" is that actors extends Actor (which is nice and proper in 
> terms of class hierarchy) with actor containing fields context, self, 
> sender() etc. That's nice and convenient but it creates a few testability 
> issues. i.e.
>
> class MyActor extends Actor {
>     private val child=context.actorOf(....) 
> ...
>     child ! "hi" // how to test the communication between MyActor and 
> child?
> }
>
> The need for "TestKit", even for unit tests, tells me that a bit of 
> refactoring could help. Ideally, at least for the unit tests, testing 
> should be done without any such dependency, only mocks. Martynas pointed 
> out the prototype Akka-Typed (
> http://doc.akka.io/docs/akka/snapshot/scala/typed.html) which I need to 
> have a look . 
>
> Note, when I talk about actor testing, I always mean message flow testing 
> (the business logic can be extracted to separate POSO classes)
>
> On 16/06/15 14:35, Richard Bradley wrote:
>  
>  How could they be?
>
>  I take it that by "POSO" you mean that an Actor would not need to 
> implement any traits? How would the framework get such an Actor to receive 
> a message, as there would be no guarantee that the object implemented a 
> "receive" method?
>
>  
> On Wednesday, June 10, 2015 at 9:09:18 PM UTC+1, Kostas kougios wrote: 
>>
>> In the other thread of mine, I explained a testability issue I have with 
>> actors which require complex messaging. But also a good question is, why 
>> are not actors POSO's? It would increase testabilty & maintainability.
>>  
>  -- 
> >>>>>>>>>> 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/QM6Y69oYECM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at http://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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to