Robolectric and Library Modules with Resource Files

I use the following project structure:

Main
|_ Project
   |_ build.gradle
|_ Library
   |_ build.gradle
|_ Settings.gradle

I included Robolectric 2.3 in my project and I created a basic unit test. The problem is that every test fails (NullPointerException), because I have some resources inside my library that cannot be loaded from unit tests. I read that Robolectric should work correctly with resource files inside library projects with 2.0.

I can not make it work. In my IntelliJ IDEA Project configuration, in the "Test Configuration" section, the working directory is installed in the project module (I also have resource files in my Project module).

Thanks, I hope someone from Robolectric can confirm me if libraries with resource files are supported.

+4
source share
1 answer

Solution . I added the project.properties file to the root of my project with the following:

target=android-18
android.library.reference.1=../MyLibrary

Now Robolectric finds resource files inside my library and my project.

+1
source

Source: https://habr.com/ru/post/1532993/


All Articles