我有这个类叫做restTemplate。它是 Spring Framework 中的 RestTemplate 对象。我试图在我的 Mockito 测试的设置方法开始时重置它,但我得到了异常:
org.mockito.exceptions.misusing.NotAMockException: Argument should be a mock, but is null!
那么我做错了什么?我在下面列出了正确的包
<context:component-scan base-package = "..."/>
它自动装配到我的测试类中,并列在我的 applicationContext-test.xml 文件中。我应该首先看什么?
编辑:
<bean id="restTemplate" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.springframework.web.client.RestTemplate" />
</bean>