My project setup
Library Project A Contains a fooJSONParser like this :
public class fooJsonParser { ... // Constructor using the input-stream public DPNodeJsonParser(InputStream inputJsonStream) { // Constructor } /** * Method that has to be executed once the class is instantiated to parse */ public parsedObject parseObj() { // Parses and prints the info }
App Project B, which uses the Library Project A
Problem
Now I have created a Test Project tester to test the App Project B and add a test case to test the fooJsonParser
class. Everytime there is new json data, I update the parse method and want to test it using the tester project and see if the parser is parsing correctly instead of installing, running the app and navigating to the screen where that new json data would be used. For accomplishing this, I am having a json file in the assets
folder of the tester. But I'm not sure how I can read the json file. I think this has something to do with MockContext
but wasn't sure how to use it as the documentation says all methods are non-functional.
Could somebody suggest a solution/provide a sample to read the asset file from a plain java object test case?
I'm fairly new to the android testing environment. Let me know If anything is unclear. I can add more information.