I am using the new unit testing feature in the Gradle 1.1 Android plugin. Let's say I have a JUnit Test like this:
public class GlossaryItemJsonTest {
@Inject
Gson gson; //this is not getting injected, so it's null
@Test
public void testDeserialization() throws Exception {
//...
}
}
How can I inject from my main scope into my test scope? I do not want to duplicate any code from my main DataModule. Traditionally I would add an injects=GsonTest.class field to the @Module annotation, but the main DataModule cannot see any classes from the test scope.
@Module(
injects = GsonTest.class //does not compile
complete = false,
library = true
)
public class DataModule {
@Provides @Singleton provideGson(){...}
}
How do inject my gson variable in the Gradle test scope?
Aucun commentaire:
Enregistrer un commentaire