【发布时间】:2016-02-19 23:55:34
【问题描述】:
我很困惑。目前我正在使用
测试我的 spring 应用程序<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
只要我想匹配正则表达式,我就很高兴。在 hamcrest 1.3 中,您需要编写自己的匹配器,我不太喜欢它。 我搜索并发现 hamcrest 2.0 内置了一些东西,例如:
assertThat(DateHelper.getActualDateForXML(), MatchesPattern.matchesPattern("\\d{4}+-\\d{2}-+\\d{2}+T\\d{2}+:\\d{2}+:\\d{2}+"));
我很高兴,我补充说:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-junit</artifactId>
<version>2.0.0.0</version>
<scope>test</scope>
</dependency>
并从 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>
现在一切仍在按我预期的那样工作,但我感觉不太舒服。因为我只能找到写 1.3 的人,并不能真正找到 hamcrest-junit 2.0 的用途。
谁能解释一下它们之间的联系?因为 hamcrest-junit 2.0 似乎包含 hamcrest 1.3 的所有内容...
谢谢本
【问题讨论】:
-
您找不到关于 2.0 和 1.3 之间差异的文档,因为该项目 [已经好几个月没有得到适当的维护][1]。如果一个活跃的提交者接管,那么我们都会知道。谢谢@CoronA。