I want to test that a file is loaded from res/raw but can't seem to get it working.
The class I'm testing is:
public class SomeService extends ContextWrapper {
public SomeService(Context base) {
super(base);
}
public BufferedReader loadSuperFile() {
InputStream inputStream = getResources().openRawResource(R.raw.superFile);
return new BufferedReader(new InputStreamReader(inputStream));
}
}
With the test class being:
@Test
public void aTest() {
SomeService someService = new SomeService(new MainActivity().getApplicationContext());
BufferedReader br = someService.loadSuperFile();
}
But I get a RuntimeException: Method getApplicationContext in android.content.ContextWrapper not mocked.
I suspect it's the context but just can't find the magic formula. Any help would be much appreciated :)
Aucun commentaire:
Enregistrer un commentaire