mercredi 3 janvier 2018

Mocking a class inside an Android app - not in unit test scope

I would like to mock an object/class inside my app (this class interacts with a 3rd party library) and I would like to be able to run my app regardless of the actual response I get from the 3rd party library.

I would like to set my own responses to the methods called.

I tried to use mockito and compile it regularly (I have used compile instead of testCompile).

I have encountered different errors with different version when trying to invoke spy or mock static creation of the mock object.

My questions:

  1. Is Mockito suitable for running inside the app or it is built only for unit testing? if it is suitable , is there a link for a boilerplate code doing that for android ?
  2. Is there any other better solution/framework other than writing the mock my self? (before I choose implementing a proxy pattern or something similar)

Aucun commentaire:

Enregistrer un commentaire