Unit Testing in MVP with one Activity

0 votes
asked Sep 13, 2017 by abish-r

In our app we have many modules, only the main module have one activity class and all other modules have only fragments. From main module I can access all the module classes and from feature modules I can't access the main. This is the architecture we are following.

For this, how we should write unit testing with jUnit. For unit testing how we will cover the business logics. All the logics are in fragment classes.

Presenter is the mediator for fragments. We are doing all the network calls in presenter and calling the fragments inside the response. If this is the case, then how I should avoid the actual volley network call.

I referred few links and I am able write only model class, if that is the case the code coverage will go down. So I want to mock the request and response and want to test presenter and fragments also.

If I am writing test case, I am not able to get the context. Activity is in main module. How should I do this, I can write unit test only in main module to get the context?

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
...