robolectric.github.io icon indicating copy to clipboard operation
robolectric.github.io copied to clipboard

Add a guide on how to provide an AndroidManifest.xml when running Robolectric in a library module

Open Nimrodda opened this issue 3 years ago • 0 comments

I tried to use Robolectric in a library module and received an error when running the test:

Attribute data@scheme at tempFile1ProcessTestManifest273304251747743144.xml requires a placeholder substitution but no value for <someParameter> is provided.

This happened due to the library module expecting the app module to provide a value for a manifest placeholder. I realized I need to somehow provide a fake AndroidManifest.xml file to the test, but couldn't find any documentation about this. After fiddling a little with the properties file and the Config annotation to set the path to the fake AndroidManifest.xml file and failing, it crossed my mind that it's possible to provide a fake AndroidManifest.xml file to instrumentation tests (androidTest) by placing a manifest in the root of the test (/library/src/androidTest) so I tried the same with /library/src/test and finally it worked!

I think it would be really useful info to include in the user guide. I don't mind making a PR to add this. Just tell me where to place it.

Nimrodda avatar Feb 03 '22 20:02 Nimrodda