When the test class is a module, the test gets created twice: first time for
the module and second for the test, this doesn't allow us to share instance
variables between the module and the test, forcing us to us statics.
To fix, on GuiceContainer change the createTest method for:
public Object createTest(Class<?> testClass, Map<Field, Object> fieldValues)
throws Exception {
FieldModule fields = new FieldModule(fieldValues);
Object newInstance = testClass.newInstance();
Injector injector;
if (Module.class.isAssignableFrom(testClass)) {
injector = Guice.createInjector(fields, (Module) newInstance);
} else {
injector = Guice.createInjector(fields);
}
injector.injectMembers(newInstance);
return newInstance;
}
Original issue reported on code.google.com by gal.dol...@gmail.com on 8 Dec 2011 at 7:41
Original issue reported on code.google.com by
gal.dol...@gmail.com
on 8 Dec 2011 at 7:41