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

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

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

      <legend id='JTIUG'><style id='JTIUG'><dir id='JTIUG'><q id='JTIUG'></q></dir></style></legend>
      <tfoot id='JTIUG'></tfoot>
        <bdo id='JTIUG'></bdo><ul id='JTIUG'></ul>

      1. 如何用 mockito 模擬 builder

        How to mock a builder with mockito(如何用 mockito 模擬 builder)
      2. <i id='4iiT3'><tr id='4iiT3'><dt id='4iiT3'><q id='4iiT3'><span id='4iiT3'><b id='4iiT3'><form id='4iiT3'><ins id='4iiT3'></ins><ul id='4iiT3'></ul><sub id='4iiT3'></sub></form><legend id='4iiT3'></legend><bdo id='4iiT3'><pre id='4iiT3'><center id='4iiT3'></center></pre></bdo></b><th id='4iiT3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4iiT3'><tfoot id='4iiT3'></tfoot><dl id='4iiT3'><fieldset id='4iiT3'></fieldset></dl></div>

        <small id='4iiT3'></small><noframes id='4iiT3'>

          <tbody id='4iiT3'></tbody>
      3. <tfoot id='4iiT3'></tfoot>

          <bdo id='4iiT3'></bdo><ul id='4iiT3'></ul>
          <legend id='4iiT3'><style id='4iiT3'><dir id='4iiT3'><q id='4iiT3'></q></dir></style></legend>

                  本文介紹了如何用 mockito 模擬 builder的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我有一個(gè)建造者:

                  class Builder{
                       private String name;
                       private String address;
                       public Builder setName(String name){
                           this.name = name;
                           return this;
                      }
                       public Builder setAddress(String address){
                           this.address = address;
                           return this;
                      }
                  
                  }
                  

                  在 mockito 中模擬構(gòu)建器會(huì)給我每個(gè)方法的 null.那么有沒(méi)有一種簡(jiǎn)單的方法可以讓構(gòu)建器在每次函數(shù)調(diào)用時(shí)返回自身,而無(wú)需使用 when().thenReturn 模擬每個(gè)函數(shù)本身.

                  Mocking the builder in mockito will gives me null for every method. So is there an easy way to get the builder return itself on every function call, without mocking every function itself using when().thenReturn.

                  推薦答案

                  你可以使用RETURN_DEEP_STUBS 模擬鏈接 API.

                  You can use RETURN_DEEP_STUBS to mock a chaining API.

                  如果您知道調(diào)用構(gòu)建器的確切順序,以下是您將如何使用它的示例:

                  If you know the exact order your builder will be called, here's an example of how you would use it:

                  Builder b = Mockito.mock(Builder.class, RETURNS_DEEP_STUBS);
                  when(b.setName("a name").setAddress("an address")).thenReturn(b);
                  assert b.setName("a name").setAddress("an address") == b; // this passes
                  

                  不幸的是,這不會(huì)為您提供一種模擬所有各種構(gòu)建器方法"的通用方式,因此它們總是返回這個(gè),看看另一個(gè)答案是你需要那個(gè).

                  Unfortunately this won't give you a generic way of mocking "all the various builder methods" so that they always return this, see the other answer is you need that.

                  這篇關(guān)于如何用 mockito 模擬 builder的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(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 語(yǔ)句之前的局部變量,這有關(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?)
                  1. <tfoot id='QC3FV'></tfoot>

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

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

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

                            主站蜘蛛池模板: 免费精品| 国产高清视频一区 | 亚洲激情在线 | 国内精品久久久久久 | 亚洲综合色自拍一区 | 99热这里有精品 | 亚洲色欲色欲www | 国产精品久久久久aaaa | 色婷婷av一区二区三区软件 | 国产羞羞视频在线观看 | 天堂综合网久久 | 亚洲色图综合 | 精品国产乱码一区二区三区a | 色av一区 | 全部免费毛片在线播放网站 | 麻豆国产一区二区三区四区 | 久久久精品网站 | 一区二区在线观看av | 成人免费久久 | 国产精品毛片在线 | 91精品欧美久久久久久久 | 国产免费视频在线 | 日本三级网站在线观看 | 特黄特黄a级毛片免费专区 av网站免费在线观看 | 成人中文字幕在线 | 欧美日日| 日日精品 | 又黑又粗又长的欧美一区 | 日韩欧美在线播放 | 伊人超碰 | 午夜网站视频 | 99热视 | 日韩一区二区三区在线视频 | 91偷拍精品一区二区三区 | 极品销魂美女一区二区 | 国产美女久久 | 日韩在线综合 | 在线视频第一页 | 亚洲精品在线免费观看视频 | 亚洲精品乱码久久久久久按摩 | av网站在线看 |