<tfoot id='CTKxy'></tfoot>

    <small id='CTKxy'></small><noframes id='CTKxy'>

  • <legend id='CTKxy'><style id='CTKxy'><dir id='CTKxy'><q id='CTKxy'></q></dir></style></legend>
      1. <i id='CTKxy'><tr id='CTKxy'><dt id='CTKxy'><q id='CTKxy'><span id='CTKxy'><b id='CTKxy'><form id='CTKxy'><ins id='CTKxy'></ins><ul id='CTKxy'></ul><sub id='CTKxy'></sub></form><legend id='CTKxy'></legend><bdo id='CTKxy'><pre id='CTKxy'><center id='CTKxy'></center></pre></bdo></b><th id='CTKxy'></th></span></q></dt></tr></i><div id='CTKxy'><tfoot id='CTKxy'></tfoot><dl id='CTKxy'><fieldset id='CTKxy'></fieldset></dl></div>
        • <bdo id='CTKxy'></bdo><ul id='CTKxy'></ul>

        Mockito、JUnit、Hamcrest、版本控制

        时间:2023-10-01
      2. <i id='gKoiS'><tr id='gKoiS'><dt id='gKoiS'><q id='gKoiS'><span id='gKoiS'><b id='gKoiS'><form id='gKoiS'><ins id='gKoiS'></ins><ul id='gKoiS'></ul><sub id='gKoiS'></sub></form><legend id='gKoiS'></legend><bdo id='gKoiS'><pre id='gKoiS'><center id='gKoiS'></center></pre></bdo></b><th id='gKoiS'></th></span></q></dt></tr></i><div id='gKoiS'><tfoot id='gKoiS'></tfoot><dl id='gKoiS'><fieldset id='gKoiS'></fieldset></dl></div>
        <legend id='gKoiS'><style id='gKoiS'><dir id='gKoiS'><q id='gKoiS'></q></dir></style></legend>
        <tfoot id='gKoiS'></tfoot>

              <bdo id='gKoiS'></bdo><ul id='gKoiS'></ul>
              • <small id='gKoiS'></small><noframes id='gKoiS'>

                  <tbody id='gKoiS'></tbody>

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

                  问题描述

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

                  By default, the required version of Hamcrest for:

                  • JUnit 4.11
                    • Hamcrest 1.3
                    • Hamcrest 1.1

                    Hamcrest 1.1 和 1.3 之间的 API 没有变化.目前我的测试用例尝试使用 Hamcrest 1.1 运行 JUnit 4.11,但我合理 确定这是一个坏主意.出于类似的原因,我怀疑尝试将 Mockito-core 1.9.5 与 Hamcrest 1.3 一起使用是 也是个坏主意.

                    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-core 1.9.5 以使用 Hamcrest 1.3
                      • 我现在真的没有时间

                    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

                    推荐答案

                    @durron597 于 2015 年 7 月 29 日更新:这个出色的答案在 2013 年是正确的,但后来因为 Mockito 的更新而过时.查看此答案.

                    我在工作中的许多 Maven 项目中使用具有 Mockito 核心依赖项和 hamcrest 1.3 的最新 JUnit.到目前为止,没有人报告这有任何问题.因此,如果这适用于您的测试,请使用所有三个的最新版本.只需确保使用 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 问题 397 的注释:此问题不与 mockito-core 一起出现.

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

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

                  上一篇:MockRestServiceServer 在集成测试中模拟后端超时 下一篇:Java 如何处理整数下溢和上溢以及如何检查它?

                  相关文章

                  最新文章

                  <small id='CRhcr'></small><noframes id='CRhcr'>

                  • <bdo id='CRhcr'></bdo><ul id='CRhcr'></ul>

                  1. <i id='CRhcr'><tr id='CRhcr'><dt id='CRhcr'><q id='CRhcr'><span id='CRhcr'><b id='CRhcr'><form id='CRhcr'><ins id='CRhcr'></ins><ul id='CRhcr'></ul><sub id='CRhcr'></sub></form><legend id='CRhcr'></legend><bdo id='CRhcr'><pre id='CRhcr'><center id='CRhcr'></center></pre></bdo></b><th id='CRhcr'></th></span></q></dt></tr></i><div id='CRhcr'><tfoot id='CRhcr'></tfoot><dl id='CRhcr'><fieldset id='CRhcr'></fieldset></dl></div>

                      <legend id='CRhcr'><style id='CRhcr'><dir id='CRhcr'><q id='CRhcr'></q></dir></style></legend>

                      <tfoot id='CRhcr'></tfoot>