Dictionary Mockito:验证参数是使用正则表达式模式的映射
我有一个函数可以执行以下操作:Dictionary Mockito:验证参数是使用正则表达式模式的映射,dictionary,groovy,mockito,Dictionary,Groovy,Mockito,我有一个函数可以执行以下操作: mock_object.install_tool name:"Python27x32', type:"CustomTool' verify(mock_object, times(1)).install_tool(argThat(hasEntry('name'))) verify(mock_object, times(1)).install_tool(argThat(hasValue('Python\\d{2}x\\d{2}'))) 测试功能时,我想验证以下内容
mock_object.install_tool name:"Python27x32', type:"CustomTool'
verify(mock_object, times(1)).install_tool(argThat(hasEntry('name')))
verify(mock_object, times(1)).install_tool(argThat(hasValue('Python\\d{2}x\\d{2}')))
测试功能时,我想验证以下内容:
mock_object.install_tool name:"Python27x32', type:"CustomTool'
verify(mock_object, times(1)).install_tool(argThat(hasEntry('name')))
verify(mock_object, times(1)).install_tool(argThat(hasValue('Python\\d{2}x\\d{2}')))
我正在尝试使用matches Matcher,但由于以下错误而失败:
预计有1名匹配者,记录了2名匹配者
我应该如何通过正则表达式匹配映射值?首先:org.hamcrest.Matchers.hasEntry需要两个参数,
只有一个参数的代码无效
hasEntry('name') // no such overload
hasEntry有2个重载:
hasEntryK键,V值
hasEntryMatcherThanks我要试试这个。我无意中使用了matches函数,但无法使用它。它是如何使用的?如果不知道它属于哪一类,我真的说不出来。java.util.regex.Matcher?这是一个完全不同的匹配者。您不能将其传递给期望Hamcrest MatcherIt为org.mockito.ArgumentMatchers.matchesThanks的方法。关于解释,请参阅