title: Android Test Project - Reading assets file to test plain java object
body: <p><strong>My project setup</strong></p>
  
  <ul>
  <li><p><em>Library Project A</em> Contains a fooJSONParser like this :</p>
  
  <pre><code>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
    }
  </code></pre></li>
  <li><p><em>App Project B</em>, which uses the <em>Library Project A</em></p></li>
  </ul>
  
  <p><strong>Problem</strong></p>
  
  <p>Now I have created a Test Project <em>tester</em> to test the <em>App Project B</em> and add a test case to test the <code>fooJsonParser</code> class. Everytime there is new json data, I update the parse method and want to test it using the <em>tester</em> 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 <code>assets</code> folder of the <em>tester</em>. But I'm not sure how I can read the json file. I think this has something to do with <code>MockContext</code> but wasn't sure how to use it as the <a href="http://developer.android.com/reference/android/test/mock/MockContext.html" rel="nofollow">documentation</a> says all methods are non-functional. </p>
  
  <p>Could somebody suggest a solution/provide a sample to read the asset file from a <a href="http://developer.android.com/guide/topics/testing/testing_android.html#JUnit" rel="nofollow">plain java object test case</a>?</p>
  
  <p>I'm fairly new to the android testing environment. Let me know If anything is unclear. I can add more information.</p>