We are writing JUnit tests for a class that uses Spring autowiring to inject a dependency which is some instance of an interface. Since the class under test never explicitly
For those people who met
java.lang.IllegalStateException: Missing @Injectable for field ***
or
java.lang.IllegalStateException: Missing @Tested class for field ***
error when using jmockit
to mock @autowired
field in spring
( or spring boot
) framework, I did below two steps to avoid above errors:
@Tested(fullyInitialized=true)
instead of @Tested
https://groups.google.com/forum/#!msg/jmockit-users/uo0S51lSX24/lQhLNN--eJcJ
1.18
or previous oneshttps://groups.google.com/forum/#!topic/jmockit-users/wMFZggsA8LM