久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <tfoot id='4NlXv'></tfoot>

    1. <small id='4NlXv'></small><noframes id='4NlXv'>

    2. <i id='4NlXv'><tr id='4NlXv'><dt id='4NlXv'><q id='4NlXv'><span id='4NlXv'><b id='4NlXv'><form id='4NlXv'><ins id='4NlXv'></ins><ul id='4NlXv'></ul><sub id='4NlXv'></sub></form><legend id='4NlXv'></legend><bdo id='4NlXv'><pre id='4NlXv'><center id='4NlXv'></center></pre></bdo></b><th id='4NlXv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4NlXv'><tfoot id='4NlXv'></tfoot><dl id='4NlXv'><fieldset id='4NlXv'></fieldset></dl></div>
      <legend id='4NlXv'><style id='4NlXv'><dir id='4NlXv'><q id='4NlXv'></q></dir></style></legend>
        <bdo id='4NlXv'></bdo><ul id='4NlXv'></ul>

      Mockito's Matcher vs Hamcrest Matcher?

      Mockito#39;s Matcher vs Hamcrest Matcher?(Mockitos Matcher vs Hamcrest Matcher?)

          <legend id='pB3eV'><style id='pB3eV'><dir id='pB3eV'><q id='pB3eV'></q></dir></style></legend>
          <i id='pB3eV'><tr id='pB3eV'><dt id='pB3eV'><q id='pB3eV'><span id='pB3eV'><b id='pB3eV'><form id='pB3eV'><ins id='pB3eV'></ins><ul id='pB3eV'></ul><sub id='pB3eV'></sub></form><legend id='pB3eV'></legend><bdo id='pB3eV'><pre id='pB3eV'><center id='pB3eV'></center></pre></bdo></b><th id='pB3eV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pB3eV'><tfoot id='pB3eV'></tfoot><dl id='pB3eV'><fieldset id='pB3eV'></fieldset></dl></div>

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

            <tbody id='pB3eV'></tbody>
            <tfoot id='pB3eV'></tfoot>

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

                本文介紹了Mockito's Matcher vs Hamcrest Matcher?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                這將是一個簡單的問題,但如果我的類路徑中包含兩個庫,我找不到它們之間的區(qū)別以及使用哪一個?

                That's going to be an easy one, but I cannot find the difference between them and which one to use, if I have both the lib's included in my classpath?

                推薦答案

                Hamcrest 匹配器方法返回 Matcher 并且 Mockito 匹配器返回 T.因此,例如:org.hamcrest.Matchers.any(Integer.class) 返回 org.hamcrest.Matcher 的實(shí)例,以及 org.mockito.Matchers.any(Integer.class)code> 返回 Integer 的一個實(shí)例.

                Hamcrest matcher methods return Matcher<T> and Mockito matchers return T. So, for example: org.hamcrest.Matchers.any(Integer.class) returns an instance of org.hamcrest.Matcher<Integer>, and org.mockito.Matchers.any(Integer.class) returns an instance of Integer.

                這意味著您只能在簽名中需要 Matcher 對象時使用 Hamcrest 匹配器 - 通常是在 assertThat 調(diào)用中.在調(diào)用模擬對象的方法的地方設(shè)置期望或驗(yàn)證時,您可以使用 Mockito 匹配器.

                That means that you can only use Hamcrest matchers when a Matcher<?> object is expected in the signature - typically, in assertThat calls. When setting up expectations or verifications where you are calling methods of the mock object, you use the Mockito matchers.

                例如(為了清楚起見,使用完全限定的名稱):

                For example (with fully qualified names for clarity):

                @Test
                public void testGetDelegatedBarByIndex() {
                    Foo mockFoo = mock(Foo.class);
                    // inject our mock
                    objectUnderTest.setFoo(mockFoo);
                    Bar mockBar = mock(Bar.class);
                    when(mockFoo.getBarByIndex(org.mockito.Matchers.any(Integer.class))).
                        thenReturn(mockBar);
                
                    Bar actualBar = objectUnderTest.getDelegatedBarByIndex(1);
                
                    assertThat(actualBar, org.hamcrest.Matchers.any(Bar.class));
                    verify(mockFoo).getBarByIndex(org.mockito.Matchers.any(Integer.class));
                }
                

                如果您想在需要 Mockito 匹配器的上下文中使用 Hamcrest 匹配器,您可以使用 org.mockito.Matchers.argThat 匹配器.它將 Hamcrest 匹配器轉(zhuǎn)換為 Mockito 匹配器.因此,假設(shè)您想以某種精度(但不多)匹配雙精度值.在這種情況下,您可以這樣做:

                If you want to use a Hamcrest matcher in a context that requires a Mockito matcher, you can use the org.mockito.Matchers.argThat matcher. It converts a Hamcrest matcher into a Mockito matcher. So, say you wanted to match a double value with some precision (but not much). In that case, you could do:

                when(mockFoo.getBarByDouble(argThat(is(closeTo(1.0, 0.001))))).
                    thenReturn(mockBar);
                

                這篇關(guān)于Mockito's Matcher vs Hamcrest Matcher?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個隨機(jī)打亂數(shù)字的 int 數(shù)組)
                Inconsistent behavior on java#39;s ==(java的行為不一致==)
                Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲為 int?)

                    <bdo id='PpLAh'></bdo><ul id='PpLAh'></ul>

                      <tfoot id='PpLAh'></tfoot>
                    • <i id='PpLAh'><tr id='PpLAh'><dt id='PpLAh'><q id='PpLAh'><span id='PpLAh'><b id='PpLAh'><form id='PpLAh'><ins id='PpLAh'></ins><ul id='PpLAh'></ul><sub id='PpLAh'></sub></form><legend id='PpLAh'></legend><bdo id='PpLAh'><pre id='PpLAh'><center id='PpLAh'></center></pre></bdo></b><th id='PpLAh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PpLAh'><tfoot id='PpLAh'></tfoot><dl id='PpLAh'><fieldset id='PpLAh'></fieldset></dl></div>

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

                        <legend id='PpLAh'><style id='PpLAh'><dir id='PpLAh'><q id='PpLAh'></q></dir></style></legend>
                            <tbody id='PpLAh'></tbody>
                        1. 主站蜘蛛池模板: 黄色91在线 | 国产精品国产a级 | 在线国产一区 | 日本aⅴ中文字幕 | 亚洲精品久久久久久一区二区 | 亚洲免费人成在线视频观看 | 欧美一级在线 | 九九久久免费视频 | 色吧色综合 | 一级毛片视频免费观看 | 国产高清视频 | 国产精品久久久久久久 | 久久中文字幕一区 | 欧美一区二区在线观看 | 久久亚洲精品国产精品紫薇 | 九九精品在线 | 狠狠艹 | 在线三级网址 | 久久精品99国产精品日本 | 偷拍亚洲色图 | 日韩在线不卡 | 怡红院怡春院一级毛片 | 亚洲激情一级片 | 欧美日日 | 欧美大片一区二区 | 久久精品国产99国产精品 | 粉嫩国产精品一区二区在线观看 | 免费视频一区二区三区在线观看 | 美国a级毛片免费视频 | 成人在线视频免费看 | 久久精品久久久 | 91热在线| 亚洲一区精品在线 | 国产午夜视频 | 在线免费观看黄a | 北条麻妃一区二区三区在线视频 | 一区二区三区免费在线观看 | 男女免费观看在线爽爽爽视频 | 欧美黄色片 | 欧美一级视频 | 日韩一区二区三区精品 |