Android Service Testing with messages

Posted by Sandeep Dhull on Stack Overflow See other posts from Stack Overflow or by Sandeep Dhull
Published on 2012-10-30T04:41:42Z Indexed on 2012/10/30 5:00 UTC
Read the original article Hit count: 135

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-testing