Using JMockit to mock autowired interface implementations

前端 未结 5 507
暖寄归人
暖寄归人 2020-12-17 18:10

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

5条回答
  •  萌比男神i
    2020-12-17 18:50

    You can use org.springframework.test.util.ReflectionTestUtils to explicitly inject your mocked ISomeInterface in your test case.

    See documentation

提交回复
热议问题