Android-style resources (currently) don't "just work" in JVM unit testing. 
You can always create a mock Resources instance, specify the behavior of 
openRawResource(...) and pass it to your code under test.

Michal

On Monday, June 22, 2015 at 3:16:45 PM UTC+1, Pierre Degand wrote:
>
> Hello, 
>
> Is it possible to have unit test's specific resources or assets ?
>
> In my main/res/raw, I have a ws.json file that is used by my production 
> code.
>
> I want in some unit test to load a modified version of this json. I would 
> like to have in test/res/raw another file called test.json and then 
> reference it in a test java file with R.raw.test.
>
> I don't want to override all the files in main/res/raw because I also 
> need them in the java test file.
>
> I tried to modify the source sets of my test but it doesnt work
>
> sourceSets {
>     test {
>         assets.srcDirs = ['src/test/res', 'src/main/res']
>     }
> }
>
>
> Is this even possible with the current build system ?
>
> Thank you.
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to