Hamcrest-使用哪个版本? 1.3或2 [英] Hamcrest - what version to use? 1.3 or 2

查看:239
本文介绍了Hamcrest-使用哪个版本? 1.3或2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑.目前,我正在使用

I am quite confused. Currently I am testing my spring application using

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
   <scope>test</scope>
</dependency>

我很高兴,只要我想匹配RegularExpressions.在hamcrest 1.3中,您需要编写自己的匹配器,我不太喜欢. 我搜索发现hamcrest 2.0内置了一些东西,例如:

I was happy as long as I wanted to match RegularExpressions. In hamcrest 1.3 you need to write your own matcher, which I did not like that much. I searched and found that hamcrest 2.0 has something build in, like:

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依赖项:

And kicked out the 1.3 hamcrest dependencies from spring-boot-starter-test:

<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的使用.

Now everything is still working as I expect it to work, but I do not feel really comfortable. Because I can just find people writing about 1.3 and can not really find the use of hamcrest-junit 2.0.

有人可以向我解释他们之间的联系吗?因为似乎hamcrest-junit 2.0具有hamcrest 1.3的所有功能...

Can somebody explain me the connection between them? Because it seems that hamcrest-junit 2.0 has everything build in from hamcrest 1.3...

感谢Ben

推荐答案

基于Hamcrest Github

Based on Hamcrest Github

  • Hamcrest Github CHANGES.md
  • Decouple the evolution of Hamcrest and JUnit
  • Is this still being maintained?

JUnit Lambda(Junit 5)

  • 最小化依赖关系(尤其是第三方)

我要接受它

My take on it

  • hamcrest-junit 2.0(应该是)是一个崭新的开始,其目标也是将hamcrest与junit脱钩
  • 与此同时,启动了Junit 5项目,该项目减少/消除了第三方依赖性

=>在这种情况下,我希望谨慎的人在继续前进之前,等待/协调JUnit 5项目.

=> In this situation, I expect it is prudent for the hamcrest guys to wait for / coordinate with the JUnit 5 project before moving forward substantially.

正如@heenenee提到的那样,那些令人难以置信的家伙开始忙于其他事情,因此目前该项目并没有发生什么事.

As @heenenee mentioned, the hamcrest guys became busy with other stuff and so not much is happening with the project at this point.

要回答

To answer

有人可以向我解释他们之间的联系吗?因为hamcrest-junit 2.0似乎具有hamcrest 1.3的所有功能

Can somebody explain me the connection between them? Because it seems that hamcrest-junit 2.0 has everything build in from hamcrest 1.3

  • hamcrest-junit 2.0开始了,但是它背后的人在(并且仍然)在其他项目之后很快就忙了起来,所以开发停止了
  • 关于JUnit 5可能还存在一些不确定性,这可能是促使进一步推迟hamcrest-junit 2.0开发直到JUnit 5发行(推测)的诱因
  • ...但是我不太舒服.因为我只能找到写1.3的人,却找不到hamcrest-junit 2.0的使用.

    ... but I do not feel really comfortable. Because I can just find people writing about 1.3 and can not really find the use of hamcrest-junit 2.0.

    目前,除了您的情况以外,没有太多动机转向hamcrest-junit 2.0. Junit 5发布后,我希望将会有更多的动力来继续前进.

    At the moment, other than for your case there is not much incentive to move to hamcrest-junit 2.0. Once Junit 5 releases I expect that there will be more incentive to move forward again.

    这篇关于Hamcrest-使用哪个版本? 1.3或2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆