【问题标题】:The method when(T) in the type Stubber is not applicable for the arguments (void)类型 Stubber 中的方法 when(T) 不适用于参数 (void)
【发布时间】:2015-09-03 15:25:20
【问题描述】:

存根 void 时出现以下错误:

类型 Stubber 中的 when(T) 方法不适用于 论据(无效)

这是我的示例代码:

doNothing().when(mockRegistrationPeristImpl.create(any(Registration.class)));

public void create(final T record) throws DataAccessException {
    try {
        entityManager.persist(record);
        entityManager.flush();
    } catch (PersistenceException ex) {}
}

我错过了什么?

【问题讨论】:

标签: mockito


【解决方案1】:

你的括号放错地方了,试试这个:

doNothing().when(mockRegistrationPeristImpl).create(any(Registration.class));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多