Android Service Testing with messages
- by Sandeep Dhull
I have a service which does its work(perform network operation) depending upon the type of message(message.what) property of the message. Then it returns the resoponse, also as a message to the requesting component(depending upon the message.replyTo).
So, i am trying to write the testcases.. But how?????
My Architecture of service is like this:
1) A component(ex. Activity) bounds to the service.
2) The component sends message to the Service(using Messenger).
3) The service has a nested class that handles the messages and execute the network call and returns a response as message to the sender(who initially sent the message and using its replyTo property).
Now to test this.. i am using Junit test cases..
So , in that ..
1) in setUp() i am binding to the service..
2) on testBusinessLogic() . i am sending the message to the service ..
Now problem is where to get the response message.