Skip to content Skip to sidebar Skip to footer

Shadowing Getfilesdir() In Robolectric 3

I'd like to shadow Context.getFilesDir() in order to 'virtualize' the filesystem my app is running in the test environment, but I can't find the right enclosing class to shadow. I

Solution 1:

I'm not really sure of what you're trying to do, but I have used the following to get the data directory on Robolectric tests:

RuntimeEnvironment.application.getApplicationContext().getFilesDir();

From that I have been able to create dummy files for whatever purpose I need in a test. Hope it helps.

Post a Comment for "Shadowing Getfilesdir() In Robolectric 3"