Stubber 类型中的 when(T) 方法不适用于参数 (void)
The method when(T) in the type Stubber is not applicable for the arguments (void)
我在存根 void 时遇到以下错误:
The method when(T) in the type Stubber is not applicable for the
arguments (void)
这是我的示例代码:
doNothing().when(mockRegistrationPeristImpl.create(any(Registration.class)));
public void create(final T record) throws DataAccessException {
try {
entityManager.persist(record);
entityManager.flush();
} catch (PersistenceException ex) {}
}
我错过了什么?
你的括号放错了,试试这个:
doNothing().when(mockRegistrationPeristImpl).create(any(Registration.class));
我在存根 void 时遇到以下错误:
The method when(T) in the type Stubber is not applicable for the arguments (void)
这是我的示例代码:
doNothing().when(mockRegistrationPeristImpl.create(any(Registration.class)));
public void create(final T record) throws DataAccessException {
try {
entityManager.persist(record);
entityManager.flush();
} catch (PersistenceException ex) {}
}
我错过了什么?
你的括号放错了,试试这个:
doNothing().when(mockRegistrationPeristImpl).create(any(Registration.class));