我正在尝试使用 jMock 创建一个模拟对象。模拟对象看起来不错 - 但问题是它没有注入到测试类。这是我的代码:
@RunWith(JMock.class)
public class FeederFilterTest {
private TestedClass service;
@Mock
private TheMockedInterface mock;
...
}
@Service
public class TestedClass {
@Autowired
private TheMockedInterface interface;
...
}
正如我所说 - 模拟对象按预期创建 - 但是当我调用使用的方法时TestClass
-TheMockInterface
我得到一个 NullPointerException。
我知道 Mockito 有@InjectMocks
- jMock 也有类似的东西吗?