我试着做这样的事情:
Matcher<String> mapKeyMatcher = Matchers.is("name");
Matcher<String> mapValueMatcher = Matchers.matchesPattern("Python\\d{2}x\\d{2}");
verify(mock_object, times(1)).install_tool(
(Map<String, String>) argThat(
hasEntry(mapKeyMatcher, mapValueMatcher)
)
);然而,我无法找到如何导入我正在使用的matchesPattern -所有版本1.2,我是不是遗漏了什么?
发布于 2021-03-16 20:23:25
解决方案:使用hamcrest而不是hamcrest-all。
<hamcrest.version>2.2</hamcrest.version>
<java-hamcrest.version>2.0.0.0</java-hamcrest.version>
<!-- HAMCREST -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
<version>${java-hamcrest.version}</version>
</dependency>https://stackoverflow.com/questions/66660385
复制相似问题