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

  • <legend id='0WjWz'><style id='0WjWz'><dir id='0WjWz'><q id='0WjWz'></q></dir></style></legend><tfoot id='0WjWz'></tfoot>
      <bdo id='0WjWz'></bdo><ul id='0WjWz'></ul>

    <small id='0WjWz'></small><noframes id='0WjWz'>

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

      2. 如何使用 PowerMockito 模擬構(gòu)造函數(shù)

        How to mock constructor with PowerMockito(如何使用 PowerMockito 模擬構(gòu)造函數(shù))
      3. <tfoot id='tea1y'></tfoot>
          <tbody id='tea1y'></tbody>
          <bdo id='tea1y'></bdo><ul id='tea1y'></ul>

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

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

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

                  本文介紹了如何使用 PowerMockito 模擬構(gòu)造函數(shù)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我第一次嘗試使用 PowerMockito 模擬類構(gòu)造函數(shù),但它不起作用.我當(dāng)前的代碼是:

                  I'm trying to mock a class constructor with PowerMockito for first time, but it doesn't work. My current code is:

                  public class Bar {
                      public String getText() {
                          return "Fail";
                      }
                  }
                  
                  public class Foo {
                      public String getValue(){
                          Bar bar= new Bar();
                          return bar.getText();
                      }
                  
                  }
                  
                  @RunWith(PowerMockRunner.class)
                  @PrepareForTest(Bar.class)
                  public class FooTest {
                      private Foo foo;
                      @Mock
                      private Bar mockBar;
                  
                      @Before
                      public void setUp() throws Exception {
                          MockitoAnnotations.initMocks(this);
                          PowerMockito.whenNew(Bar.class).withNoArguments().thenReturn(mockBar);
                          foo= new Foo();
                      }
                  
                      @Test
                      public void testGetValue() throws Exception {
                          when(mockBar.getText()).thenReturn("Success");
                          assertEquals("Success",foo.getValue());
                  
                      }
                  }
                  

                  測試失敗,因?yàn)榉祷刂禐镕ail".我的問題在哪里?

                  The test fails because the returned value is "Fail". Where is my problem?

                  推薦答案

                  好的,找到答案了,需要調(diào)用

                  Okey, found the answer, you need to call to

                  @PrepareForTest(Foo.class)
                  

                  而不是

                  @PrepareForTest(Bar.class)
                  

                  這篇關(guān)于如何使用 PowerMockito 模擬構(gòu)造函數(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?(如何檢測 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?)

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

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

                        <tbody id='KQYmw'></tbody>

                          <bdo id='KQYmw'></bdo><ul id='KQYmw'></ul>
                        • <legend id='KQYmw'><style id='KQYmw'><dir id='KQYmw'><q id='KQYmw'></q></dir></style></legend>
                            主站蜘蛛池模板: 国产二区精品视频 | 欧美日韩不卡合集视频 | 91午夜在线 | 国产精品国产成人国产三级 | 午夜av免费 | 久久精品国产亚洲一区二区三区 | 中文字幕日韩欧美一区二区三区 | 国外成人在线视频 | 国产视频观看 | 国产一区欧美一区 | 人人爽日日躁夜夜躁尤物 | 精品欧美一区二区三区精品久久 | 欧美综合一区二区三区 | 岛国毛片 | 亚洲精品视频在线观看视频 | 国产日韩在线观看一区 | 91看片视频 | 久久高清国产 | 97精品国产 | 天天操操| 一区二区在线看 | 日韩中文字幕 | 中文字幕免费在线 | 亚洲一区二区三区免费在线观看 | 密色视频| 成人激情视频在线 | 日韩一区av| 国产精品久久久久久久久久免费看 | 久草电影网 | 操夜夜| 国产我和子的乱视频网站 | 亚洲视频在线看 | 日本一区二区影视 | 草草影院ccyy | 91中文在线观看 | 日韩精品在线播放 | 国产精品一区二区无线 | 欧美在线a| 精品国产乱码久久久久久久久 | 一区二区三区在线电影 | 欧美日韩综合一区 |