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

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

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

      1. 多個級別的@Mock 和@InjectMocks

        Multiple levels of @Mock and @InjectMocks(多個級別的@Mock 和@InjectMocks)
      2. <legend id='8jhkY'><style id='8jhkY'><dir id='8jhkY'><q id='8jhkY'></q></dir></style></legend>

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

              <small id='8jhkY'></small><noframes id='8jhkY'>

                <tbody id='8jhkY'></tbody>

              1. <tfoot id='8jhkY'></tfoot>

                  本文介紹了多個級別的@Mock 和@InjectMocks的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  所以我知道在 Mockito 中,@InjectMocks 會通過 @Mock 的注解注入任何它可以注入的東西,但是如何處理這種情況呢?

                  So I understand that in Mockito @InjectMocks will inject anything that it can with the annotation of @Mock, but how to handle this scenario?

                  @Mock
                  private MockObject1 mockObject1;
                  
                  @Mock
                  private MockObject2 mockObject2;
                  
                  @InjectMocks
                  private SystemUnderTest systemUnderTest = new SystemUnderTest();
                  

                  假設(shè) MockObject2 有一個 MockObject1 類型的屬性,而 SystemUnderTest 有一個 MockObject2 類型的屬性.我想將 mockObject1 注入到 mockObject2 中,并將 mockObject2 注入到 systemUnderTest 中.

                  Imagine that MockObject2 has an attribute that is of type MockObject1, and SystemUnderTest has an attribute of type MockObject2. I would like to have mockObject1 injected into mockObject2, and mockObject2 injected into systemUnderTest.

                  這可以通過注釋實現(xiàn)嗎?

                  Is this possible with annotations?

                  推薦答案

                  由于我在這里沒有得到任何回復(fù),所以我在 Mockito 論壇上提問.這是討論的鏈接:https://groups.google.com/d/topic/mockito/hWwcI5UHFi0/討論

                  Since I didn't get any response here I asked on the Mockito forums. Here is a link to the discussion: https://groups.google.com/d/topic/mockito/hWwcI5UHFi0/discussion

                  總結(jié)答案,從技術(shù)上講,這會破壞嘲笑的目的.您實際上應(yīng)該只模擬 SystemUnderTest 類所需的對象.在本身就是模擬的對象中模擬事物是毫無意義的.

                  To summarize the answers, technically this would kind of defeat the purpose of mocking. You should really only mock the objects needed by the SystemUnderTest class. Mocking things within objects that are themselves mocks is kind of pointless.

                  如果你真的想這樣做,@spy 可以提供幫助

                  If you really wanted to do it, @spy can help

                  這篇關(guān)于多個級別的@Mock 和@InjectMocks的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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)建一個隨機打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲為 int?)
                    <tbody id='rm83o'></tbody>

                    <legend id='rm83o'><style id='rm83o'><dir id='rm83o'><q id='rm83o'></q></dir></style></legend>
                  1. <small id='rm83o'></small><noframes id='rm83o'>

                    <tfoot id='rm83o'></tfoot>
                    <i id='rm83o'><tr id='rm83o'><dt id='rm83o'><q id='rm83o'><span id='rm83o'><b id='rm83o'><form id='rm83o'><ins id='rm83o'></ins><ul id='rm83o'></ul><sub id='rm83o'></sub></form><legend id='rm83o'></legend><bdo id='rm83o'><pre id='rm83o'><center id='rm83o'></center></pre></bdo></b><th id='rm83o'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rm83o'><tfoot id='rm83o'></tfoot><dl id='rm83o'><fieldset id='rm83o'></fieldset></dl></div>
                      <bdo id='rm83o'></bdo><ul id='rm83o'></ul>
                          1. 主站蜘蛛池模板: 99精品欧美一区二区三区综合在线 | 久久中文免费视频 | 日韩欧美国产一区二区 | 日韩精品在线看 | 在线观看www | 亚洲精品无 | 久久成人一区 | av一区二区三区四区 | 国产精品不卡一区 | 美女日批免费视频 | 日日躁狠狠躁aaaaxxxx | 午夜精品久久久久久久久久久久 | 免费三级网 | 亚洲精品在线看 | 国产小网站 | 国产精品欧美精品日韩精品 | 精品成人在线观看 | 久久亚洲一区二区 | 亚洲精品久久久蜜桃网站 | 欧美国产精品一区二区三区 | 亚洲色图综合 | 亚洲视频手机在线 | 午夜精品久久久久久久99黑人 | 亚洲最新在线视频 | 国产激情免费视频 | 久久精品a级毛片 | 依人成人 | 91久久精品日日躁夜夜躁国产 | 性高湖久久久久久久久aaaaa | 欧美日韩成人影院 | 久久国产精品免费 | 国产网站在线免费观看 | 欧美亚州综合 | 久久男人天堂 | 日韩视频a | 天天操天天射综合 | 亚洲福利 | 日本黄色片免费在线观看 | 欧美影院久久 | 在线黄色网 | 久久久无码精品亚洲日韩按摩 |