我被困在试图验证侦听器实现的参数。
来自Listener
接口的方法:
public void settingsAdded(List<EditJobSettings> addedSettings);
我想要做的是检查列表中是否存在预期的对象。
测试(省略不相关的代码):
@Test
public void initiallyAddColorAndAlignTile() {
mSettings.add(mColorSetting);
// This method calls the listener method and passes the added settings as argument
mStatusNotifier.notifySettingsUpdates(mSettings);
// Here I get stuck: this does not compile, but I can't find how to work around this. Is there a way to specify a generic list as argument?
ArgumentCaptor<List<EditJobSettingsSet>> argument = (List<EditJobSettingsSet>) ArgumentCaptor.forClass(List.class);
verify(mEditJobListener).settingsAdded(argument.capture());
assertTrue(argument.getValue().contains(mColorSettings));
}
提前致谢。