久久久久久久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 可以在方法調用時根據參數的值來驗證參數

      Can Mockito verify parameters based on their values at the time of method call?(Mockito 可以在方法調用時根據參數的值來驗證參數嗎?)

        <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 可以在方法調用時根據參數的值來驗證參數嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

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

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

                請注意,協作者實際上是一個間諜對象,而不是一個模擬對象.這個測試用例將失敗,因為即使 run() 是使用等于 expectedList 的參數調用的,但它已被修改,因為它的當前值不再等于 expectedList.但是,這是它應該工作的方式,所以我想知道是否有辦法讓 Mockito 在調用方法時存儲參數的快照,并根據這些值而不是最近的值來驗證它們.

                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.

                推薦答案

                在調用方法時使用 Answer 檢查參數的值.如果值錯誤,您可以在 Answer 中拋出 AssertionError,或者您可以存儲該值,并在最后進行斷言.

                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.

                這篇關于Mockito 可以在方法調用時根據參數的值來驗證參數嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)
                • <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'>

                        • 主站蜘蛛池模板: 美女爽到呻吟久久久久 | 国产精品激情在线 | 精品国产伦一区二区三区观看方式 | 精品一区免费 | www.狠狠干 | 色网在线看 | 欧美日韩黄色一级片 | 九一视频在线观看 | 色婷婷综合久久久中字幕精品久久 | 成人国产一区二区三区精品麻豆 | 国产成人免费网站 | 国产伦精品一区二区三区高清 | 国产激情视频网站 | 能免费看的av | 国产精品91视频 | 欧美一区二区三区在线 | 超碰97免费 | 久久精品二区亚洲w码 | 久久久成人动漫 | 成年人在线视频 | 国产精品日韩欧美一区二区三区 | 日韩欧美在线一区 | 国产精品成人一区二区三区 | 成人午夜免费视频 | 成人在线 | 国产精品一区在线 | 国产在线一级片 | 亚洲视频欧美视频 | 久久精品久久久久久 | 亚洲视频一区二区 | 中文字字幕一区二区三区四区五区 | 国内av在线| 丁香五月缴情综合网 | 精品国偷自产在线 | 国产精品国产a | 一级毛片色一级 | 成人午夜电影网 | 久久久久久久电影 | 久久久久久久91 | 女人牲交视频一级毛片 | 国产精品揄拍一区二区 |