我很困惑.目前我正在测试我的弹簧应用程序
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
只要我想匹配RegularExpressions,我就很开心.在hamcrest 1.3中你需要编写自己的匹配器,我不喜欢这么多.我搜索并发现hamcrest 2.0内置了一些内容,例如:
assertThat(DateHelper.getActualDateForXML(), MatchesPattern.matchesPattern("\\d{4}+-\\d{2}-+\\d{2}+T\\d{2}+:\\d{2}+:\\d{2}+"));
Run Code Online (Sandbox Code Playgroud)
我很高兴,我补充说:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-junit</artifactId>
<version>2.0.0.0</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
并从spring-boot-starter-test中踢出了1.3个hamcrest依赖项:
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</exclusion>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
Run Code Online (Sandbox Code Playgroud)
现在一切都在按照我的预期工作,但我觉得不舒服.因为我可以找到写大约1.3的人,并且无法真正找到使用hamcrest-junit 2.0.
有人可以解释一下他们之间的联系吗?因为看起来hamcrest-junit 2.0的所有内容都来自hamcrest 1.3 ......
谢谢Ben