Reputation: 5168
I am trying to write some tests with classes that use roboguice. Unfortunately it seems that guice is not injecting anything at all.
My setup is like so...
<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="roboguice_modules"> <item>com.evertaletest</item> </string-array> </resources>
Does this setup seems correct? Any class that is injected is null at the moment
Upvotes: 1
Views: 286
Reputation: 2655
I believe the <item>
entry needs to give the name of your module class, not simply the package.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="roboguice_modules">
<item>com.evertaletest.YourModuleForCode</item>
</string-array>
</resources>
But that will only be relevant for your production code. For tests, you will have to set your module in code instead of using XML.
In your test setup:
RoboGuice.setBaseApplicationInjector(application,
RoboGuice.DEFAULT_STAGE, new YourModuleForTest());
Upvotes: 1