详细信息

建议类型:可模拟调用

是否可在首选项配置:是

过滤器分类:模拟

说明

当 UTA 检测到在模拟对象上调用了未模拟的方法时,将显示此建议。详细信息,请参阅创建模拟

示例

public static class Example {	
    boolean performAction(IArg arg)
    {
        return arg.mockable();
    }
}
	
public interface IArg {
    boolean mockable();
}

@Test
public void testMockable()
{
    IArg example = mock(IArg.class);
    Example underTest = new Example();
    underTest.performAction(example);

点击模拟它链接,向测试中添加用于修改模拟所需的元素:

boolean mockableResult = false; // UTA: default value
when(example.mockable()).thenReturn(mockableResult);