久久久久久久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?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

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

                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 的實例,以及 org.mockito.Matchers.any(Integer.class)code> 返回 Integer 的一個實例.

                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 調用中.在調用模擬對象的方法的地方設置期望或驗證時,您可以使用 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 匹配器轉換為 Mockito 匹配器.因此,假設您想以某種精度(但不多)匹配雙精度值.在這種情況下,您可以這樣做:

                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);
                

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

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

                相關文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                How to convert Integer to int?(如何將整數轉換為整數?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                Inconsistent behavior on java#39;s ==(java的行為不一致==)
                Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 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. 主站蜘蛛池模板: 国产区在线 | 日韩视频在线免费观看 | 国产精品自拍av | 亚洲91av| 国产精品一码二码三码在线 | 欧美中文字幕在线 | 国产精品久久久久久久久免费相片 | 美女操网站 | 国产一区视频在线 | 亚洲精品日韩在线观看 | 亚洲欧美日韩在线 | 亚洲国产精品91 | 欧美人妇做爰xxxⅹ性高电影 | 亚洲欧美中文日韩在线 | 国产第一页在线观看 | 亚洲一区二区电影在线观看 | 国产精品日韩欧美一区二区三区 | 涩涩视频网站在线观看 | 自拍视频在线观看 | 欧美日韩一区二区在线观看 | 久久这里只有精品首页 | 久久精品手机视频 | 成人免费视频在线观看 | 精品无码久久久久久国产 | 亚洲精品久久久久国产 | 97伦理最新伦理 | 日韩精品视频在线免费观看 | 中文字幕在线观看视频网站 | 九九热在线精品视频 | 久久日韩粉嫩一区二区三区 | 亚洲 欧美 另类 日韩 | 久久精品视频在线观看 | 亚洲欧洲一区 | 国产成人精品一区二区三区在线 | 伊人久久免费视频 | 亚洲精品乱码久久久久久蜜桃91 | 日韩www | 国产高清一区二区三区 | 中文字幕亚洲精品 | 正在播放国产精品 | 国产精品视频一二三区 |