Testing parsers

There are many occasions where your Android application relies on external XML, JSON messages, or documents obtained from web services. These documents are used for data interchange between the local application and the server. There are many use cases where XML or JSON documents are obtained from the server or generated by the local application to be sent to the server. Ideally, methods invoked by these activities have to be tested in isolation to have real unit tests, and to achieve this, we need to include some mock files somewhere in our APK to run the tests.

But the question is where can we include these files?

Let's find out.

Android assets

To begin, a brief review of the assets' definition can be found in the Android SDK documentation: ...

Get Learning Android Application Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.