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

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

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

  1. <legend id='P23l5'><style id='P23l5'><dir id='P23l5'><q id='P23l5'></q></dir></style></legend>
    • <bdo id='P23l5'></bdo><ul id='P23l5'></ul>

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

      Mockito 可以在方法調(diào)用時(shí)根據(jù)參數(shù)的值來驗(yàn)證參數(shù)

      Can Mockito verify parameters based on their values at the time of method call?(Mockito 可以在方法調(diào)用時(shí)根據(jù)參數(shù)的值來驗(yàn)證參數(shù)嗎?)

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

        <tfoot id='emiOj'></tfoot>

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

        <legend id='emiOj'><style id='emiOj'><dir id='emiOj'><q id='emiOj'></q></dir></style></legend>
          • <bdo id='emiOj'></bdo><ul id='emiOj'></ul>

                本文介紹了Mockito 可以在方法調(diào)用時(shí)根據(jù)參數(shù)的值來驗(yàn)證參數(shù)嗎?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我有一個(gè) Foo 類,它是 SUT 和一個(gè) Bar 類,它是它的合作者.Foo 調(diào)用 Bar 上的 run(List values) 并以expectedList"作為參數(shù).然后,Foo 將向這個(gè) List 添加更多元素,使其狀態(tài)與調(diào)用 run().這是我的測(cè)試用例.

                I have a Foo class which is SUT and a Bar class, which is its collaborator. Foo calls run(List<Object> values) on the Bar with "expectedList" as an argument. Then, Foo will add a few more elements to this List so that its state will be different from what it was at the time of calling run(). Here's my test case.

                @Test
                public void testFoo() {
                    Bar collaborator = spy(new Bar()); 
                    Foo sut = new Foo(collaborator);
                    verify(collaborator).run(expectedList);
                }
                

                請(qǐng)注意,協(xié)作者實(shí)際上是一個(gè)間諜對(duì)象,而不是一個(gè)模擬對(duì)象.這個(gè)測(cè)試用例將失敗,因?yàn)榧词?run() 是使用等于 expectedList 的參數(shù)調(diào)用的,但它已被修改,因?yàn)樗漠?dāng)前值不再等于 expectedList.但是,這是它應(yīng)該工作的方式,所以我想知道是否有辦法讓 Mockito 在調(diào)用方法時(shí)存儲(chǔ)參數(shù)的快照,并根據(jù)這些值而不是最近的值來驗(yàn)證它們.

                Note that the collaborator is actually a spy object rather than a mock. This test case will fail because even though run() was called with an argument equal to expectedList, it was modified since and its current value no longer equals expectedList. However, this is the way it is supposed to work, so I'm wondering if there's a way to have Mockito store the snapshot of parameters when a method is called and verify them based on these values rather than the most recent values.

                推薦答案

                在調(diào)用方法時(shí)使用 Answer 檢查參數(shù)的值.如果值錯(cuò)誤,您可以在 Answer 中拋出 AssertionError,或者您可以存儲(chǔ)該值,并在最后進(jìn)行斷言.

                Use an Answer to check the value of the argument when the method is called. You can either throw an AssertionError within the Answer if the value is wrong, or you can store the value, and do your assertion at the end.

                這篇關(guān)于Mockito 可以在方法調(diào)用時(shí)根據(jù)參數(shù)的值來驗(yàn)證參數(shù)嗎?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測(cè) 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)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                Inconsistent behavior on java#39;s ==(java的行為不一致==)
                Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 int?)
                • <tfoot id='yGcAn'></tfoot>
                    <bdo id='yGcAn'></bdo><ul id='yGcAn'></ul>

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

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

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

                        • 主站蜘蛛池模板: 中文字幕专区 | 亚洲成人免费在线观看 | 九一视频在线播放 | 日日操操| 中文字幕一区二区三区精彩视频 | 黄视频网址| 99久久久无码国产精品 | 亚洲福利在线视频 | 精品久久一区二区三区 | 视频在线一区二区 | 天天爽天天干 | 国产精品揄拍一区二区 | 日本成人毛片 | a a毛片 | 在线观看av不卡 | 国内自拍真实伦在线观看 | 亚洲日本成人 | 91免费看片 | 久久久成人一区二区免费影院 | 日日骚网| 五月香婷婷 | 日日夜夜天天久久 | 免费播放一级片 | 中文字幕日韩一区 | 欧美8一10sex性hd | 国产亚洲一区二区三区 | 亚洲精品在线播放 | 日本中文字幕在线观看 | 美女亚洲一区 | 这里只有精品999 | 精品一区在线 | 亚洲国产成人久久久 | 日韩另类 | 免费成人毛片 | 男人影音 | 精品国产免费一区二区三区演员表 | 亚洲成人黄色 | 色婷婷在线视频 | 国产色| 精品欧美一区二区三区久久久 | 免费看啪啪网站 |