Netflix / governator

Governator is a library of extensions and utilities that enhance Google Guice to provide: classpath scanning and automatic binding, lifecycle management, configuration to field mapping, field validation and parallelized object warmup.
Apache License 2.0
825 stars 180 forks source link

Handling @Configuration when working with mocked objects #350

Open AlexKolpa opened 7 years ago

AlexKolpa commented 7 years ago

I've been struggling with this for a while now, but couldn't find a solution, hence this question:

When trying to inject a mocked (using Mockito) class that has an @Configuration annotation, I always get an error like this:

java.lang.Error: java.lang.Exception: Failed to bind property 'someKey' for instance of 'com.example.SomeClass$$EnhancerByMockitoWithCGLIB$$201380a1'

From what I can tell, this is governator's MembersInjectorImpl that tries to inject the configuration values, however I have not found a way to disable this during testing. I was hoping someone here could provide me with some answers.