I ran into some frustrations while trying to use Robolectric and the Android Maven Plugin. The tests are not included in the same project as the main code, because Eclipse likes to bundle all the tests into the main apk when testing. This causes its own nightmares and headaches. So I separated the tests out into their own project. When running the tests from the command line I was having NullPointer and ClassNotFound exceptions occurring. Took a bit to find it, but the magic formula is the following configuration entry for your surefire-test-plugin:
<plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.13</version> <configuration> <workingDirectory>../../serenity-app</workingDirectory> </configuration> </plugin>
Basically, Robolectric expects to be able to find resources in the same project as it is being run, unfortunately if you separate the tests out so they behave nicely with ADT, you have to point the working directory back to the root of your apps directory. Once I did this, all the tests started working.