1

I'm trying to write some tests for Android for the first time.

I have an app that calls server (via AsyncTask) in OnCreate function to get some settings. But I don't want to call server when running my instrumented tests.

Currently I have achieved this by setting some static variable in @BeforeClass function and then I'm checking this variable in function that calls server.

Is there any other less ugly solution for this?

Brontes
  • 134
  • 5
  • 1
    Some possibilities here: https://stackoverflow.com/q/28550370/1363731 – mikejonesguy Oct 10 '18 at 22:17
  • Thank you for answer. Was more looking for answer in a way that I would just define something / mock something in a test so I wouldn't need to add ifs in main code. – Brontes Oct 12 '18 at 05:48

0 Answers0