Juan Herrero Diaz
Juan Herrero Diaz

Reputation: 843

Robolectric and Library modules with resource files

I am using the following project structure:

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

I have included Robolectric 2.3 in my project and I've 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 the unit tests. I've read that Robolectric should correctly work with resource files inside library projects since 2.0.

I cannot make it run. In my IntelliJ IDEA Project configuration, under Test configuration, the working directory is set to the Project module (I have some resource files under my Project module also).

Thank you, I hope someone from Robolectric could confirm me if libraries with resource files are supported.

Upvotes: 4

Views: 895

Answers (1)

Juan Herrero Diaz
Juan Herrero Diaz

Reputation: 843

Solution: I added a project.properties file at 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.

Upvotes: 1

Related Questions