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

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

  • <small id='KQ1Ks'></small><noframes id='KQ1Ks'>

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

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

        mockito 驗證與 ArgumentCaptor 的交互

        mockito verify interactions with ArgumentCaptor(mockito 驗證與 ArgumentCaptor 的交互)

            <tbody id='PEulG'></tbody>
            1. <small id='PEulG'></small><noframes id='PEulG'>

                <bdo id='PEulG'></bdo><ul id='PEulG'></ul>
                <tfoot id='PEulG'></tfoot>

                  <legend id='PEulG'><style id='PEulG'><dir id='PEulG'><q id='PEulG'></q></dir></style></legend>
                  <i id='PEulG'><tr id='PEulG'><dt id='PEulG'><q id='PEulG'><span id='PEulG'><b id='PEulG'><form id='PEulG'><ins id='PEulG'></ins><ul id='PEulG'></ul><sub id='PEulG'></sub></form><legend id='PEulG'></legend><bdo id='PEulG'><pre id='PEulG'><center id='PEulG'></center></pre></bdo></b><th id='PEulG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PEulG'><tfoot id='PEulG'></tfoot><dl id='PEulG'><fieldset id='PEulG'></fieldset></dl></div>
                • 本文介紹了mockito 驗證與 ArgumentCaptor 的交互的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  要檢查與方法調用中的參數屬于某種類型的模擬的交互次數,可以這樣做

                  To check the number of interactions with a mock where the parameter in the method call is of a certain type, one can do

                  mock.someMethod(new FirstClass());
                  mock.someMethod(new OtherClass());
                  verify(mock, times(1)).someMethod(isA(FirstClass.class));
                  

                  這要歸功于對 isA 的調用,因為 someMethod 被調用了兩次,但只有一次使用參數 FirstClass

                  This will pass thanks to the call to isA since someMethod was called twice but only once with argument FirstClass

                  然而,當使用 ArgumentCaptor 時,這種模式似乎是不可能的,即使 Captor 是為特定參數 FirstClass

                  However, this pattern seems to not be possible when using an ArgumentCaptor, even if the Captor was created for the particular argument FirstClass

                  這不起作用

                  mock.someMethod(new FirstClass());
                  mock.someMethod(new OtherClass());
                  ArgumentCaptor<FirstClass> captor = ArgumentCaptor.forClass(FirstClass.class);
                  verify(mock, times(1)).someMethod(captor.capture());
                  

                  它說模擬被多次調用.

                  在捕獲參數以供進一步檢查時,有什么方法可以完成此驗證?

                  Is there any way to accomplish this verification while capturing the argument for further checking?

                  推薦答案

                  我建議使用 Mockito 的 Hamcrest 集成為其編寫一個好的、干凈的匹配器.這允許您將驗證與傳遞參數的詳細檢查結合起來:

                  I recommend using Mockito's Hamcrest integration to write a good, clean matcher for it. That allows you to combine the verification with detailed checking of the passed argument:

                  verify(mock, times(1)).someMethod(argThat(personNamed("Bob")));
                  
                  Matcher<Person> personNamed(final String name) {
                      return new TypeSafeMatcher<Person>() {
                          public boolean matchesSafely(Person item) {
                              return name.equals(item.getName());
                          }
                          public void describeTo(Description description) {
                              description.appendText("a Person named " + name);
                          }
                      };
                  }
                  

                  匹配器通常會導致更易讀的測試和更有用的測試失敗消息.它們也往往是非??芍赜玫模鷷l現自己建立了一個為測試您的項目量身定制的庫.最后,您還可以使用 JUnit 的 Assert.assertThat() 將它們用于正常的測試斷言,因此您可以雙重使用它們.

                  Matchers generally lead to more readable tests and more useful test failure messages. They also tend to be very reusable, and you'll find yourself building up a library of them tailored for testing your project. Finally, you can also use them for normal test assertions using JUnit's Assert.assertThat(), so you get double use out of them.

                  這篇關于mockito 驗證與 ArgumentCaptor 的交互的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)

                  1. <tfoot id='UHmX2'></tfoot>

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

                        • <legend id='UHmX2'><style id='UHmX2'><dir id='UHmX2'><q id='UHmX2'></q></dir></style></legend>
                            <tbody id='UHmX2'></tbody>

                        • <i id='UHmX2'><tr id='UHmX2'><dt id='UHmX2'><q id='UHmX2'><span id='UHmX2'><b id='UHmX2'><form id='UHmX2'><ins id='UHmX2'></ins><ul id='UHmX2'></ul><sub id='UHmX2'></sub></form><legend id='UHmX2'></legend><bdo id='UHmX2'><pre id='UHmX2'><center id='UHmX2'></center></pre></bdo></b><th id='UHmX2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='UHmX2'><tfoot id='UHmX2'></tfoot><dl id='UHmX2'><fieldset id='UHmX2'></fieldset></dl></div>
                          • <bdo id='UHmX2'></bdo><ul id='UHmX2'></ul>
                            主站蜘蛛池模板: 日韩一区二区三区在线 | 黄视频免费 | 在线啊v | 国产精品特级毛片一区二区三区 | 伊人精品国产 | 91毛片在线看 | 成人伊人 | 亚洲经典一区 | 精品一级 | 精品国产欧美 | 春色av| 蜜臀久久99精品久久久久野外 | 特一级毛片 | 日韩一二区在线 | 久久偷人 | 久久亚洲一区二区三 | 中文精品视频 | 亚洲精品国产a久久久久久 午夜影院网站 | 欧美日韩国产一区二区三区不卡 | 日本黄色激情视频 | 日韩一级免费看 | jav成人av免费播放 | 国产精品地址 | 午夜精品久久久久久久久久久久久 | 国产精品免费看 | 黄色大片网站 | 国产精品免费一区二区三区四区 | 91色视频在线观看 | 超碰人人在线 | 欧美激情精品久久久久久 | 日日干日日操 | 综合另类| 国产精品久久久久久久久久久免费看 | 特级黄一级播放 | 91免费看片 | 国产精品久久久久久 | www.av7788.com| 日韩欧美1区2区 | 日本不卡视频 | 久久夜视频 | 九色91视频 |