Mockito,JUnit,Hamcrest,版本控制 [英] Mockito, JUnit, Hamcrest, Versioning

查看:205
本文介绍了Mockito,JUnit,Hamcrest,版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,Hamcrest所需的版本为:

By default, the required version of Hamcrest for:


  • JUnit 4.11

    • Hamcrest 1.3


    • Hamcrest 1.1

    • Hamcrest 1.1

    Hamcrest 1.1和1.3之间没有对API进行更改。目前我的测试用例尝试使用Hamcrest 1.1运行JUnit 4.11,但我合理地确定这是一个坏主意。由于类似的原因,我怀疑尝试使用Hamcrest 1.3的Mockito-core 1.9.5是也是一个坏主意。

    There were not insiginifcant API changes between Hamcrest 1.1 and 1.3. Currently my test cases attempt to run JUnit 4.11 with Hamcrest 1.1, but I'm reasonably sure that this is a bad idea. For similar reasons, I suspect that trying to use Mockito-core 1.9.5 with Hamcrest 1.3 is also a bad idea.

    该怎么办?


    1. 使用Hamcrest 1.1与最新的JUnit和Mockito

    2. 使用Hamcrest 1.3与最新的JUnit和Mockito

    3. 尝试补丁Mockito核心1.9.5使用Hamcrest 1.3

      • 时间我真的没有在这一刻

    strong>更新2015-06-12: Mockito 1.10.19和2.0.13-beta都使用Hamcrest 1.1

    UPDATE 2015-06-12: Both Mockito 1.10.19 and 2.0.13-beta still use Hamcrest 1.1

    推荐答案

    2015年7月29日更新by @ durron597:这个很好的答案是正确的然而,在2013年,Mockito的更新已经过时了。 看到这个答案。



    我用最新的JUnit与Mockito核心依赖和hamcrest 1.3在许多Maven项目中工作。到目前为止,没有人报告任何问题。所以如果这个测试适用于所有这三个测试的最新版本。只需确保使用mockito核心,而不是全部。

    Update July 29, 2015 by @durron597: This excellent answer was correct in 2013, however it has since been rendered obsolete by an update to Mockito. See this answer.

    I use latest JUnit with Mockito core dependency and hamcrest 1.3 in many Maven projects at work. Till now nobody reported any problem with this. So if this works for your tests go with the newest Version for all three. Just ensure to use mockito core instead of all.

    所以我建议使用选项2以获得更新版本的所有好处。如果您确实有任何疑问可以使用选项4,这是最安全的选项。但是当然,你可以选择2,而在不久的将来,任何事情都会是错误的,你可以切换到选项2.或者从那时起,一个更新的mockito已经在那里解决了。

    So I would recommend to go with option 2 to have all benefits of the newer versions. If you are really in doubt that anything could go wrong use option 4 which is the safest one. But of course you could go with option 2 and when in the near future anything would be wrong you could switch to option 2. Or since then a newer mockito is already out there solving this.

    mockito Issue 397 的注意事项:此问题不出现与mockito核心。

    Note from mockito Issue 397: This problem does not appear with mockito-core.

    这篇关于Mockito,JUnit,Hamcrest,版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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