【发布时间】:2012-03-16 10:14:29
【问题描述】:
我正在尝试使用 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 也有类似的东西吗?
【问题讨论】:
标签: annotations jmock inject