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

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

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

        <tfoot id='DVnzQ'></tfoot>
        <legend id='DVnzQ'><style id='DVnzQ'><dir id='DVnzQ'><q id='DVnzQ'></q></dir></style></legend>

        doThrow 中看起來正確的 Mockito 異常

        Mockito exception in doThrow that looks correct(doThrow 中看起來正確的 Mockito 異常)

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

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

            <tfoot id='T3pgN'></tfoot>
                <bdo id='T3pgN'></bdo><ul id='T3pgN'></ul>
                  <tbody id='T3pgN'></tbody>
                  本文介紹了doThrow 中看起來正確的 Mockito 異常的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在嘗試模擬一個方法以查看我是否正確處理了異常.這是據(jù)我所知.

                  I'm trying to mock a method to see if I handle an exception correctly. This is as far as I get.

                  界面:

                  interface SampleManager {
                      void deleteVariome(String specimenId, String analysisId) throws Exception;
                      // ...
                  }
                  

                  單元測試:

                  // ...
                  SampleManger sampleManager = mock(SampleManager.class);
                  
                  // below is line 753
                  doThrow(Exception.class).when(sampleManager).deleteVariome(sample1.getId(), analysisId);
                  

                  結(jié)果:

                  org.mockito.exceptions.misusing.UnfinishedStubbingException: 
                  Unfinished stubbing detected here:
                  -> at ...server.ArchiveManagerImplUTest.deleteVariomeFails(ArchiveManagerImplUTest.java:753)
                  
                  E.g. thenReturn() may be missing.
                  Examples of correct stubbing:
                      when(mock.isOk()).thenReturn(true);
                      when(mock.isOk()).thenThrow(exception);
                      doThrow(exception).when(mock).someVoidMethod(); <-- this looks a log like what I did!
                  
                  Hints:
                  
                   1. missing thenReturn()
                  
                   2. you are trying to stub a final method, you naughty developer! <-- I have a lot of other mocks of this interface in this test that work.
                  

                  推薦答案

                  從我剛剛遇到的一個相同問題中,我懷疑 sample 是一個 mock,并且您將 sample 存根.getId() 其他地方?無論如何,這在我的情況下導(dǎo)致了這個問題.

                  From an identical issue that I just ran into, I suspect that sample is a mock, and you stubbed sample.getId() elsewhere? That caused this problem in my case, anyhow.

                  由于某種原因,如果您以這種方式傳遞給與 doThrow 一起使用的存根的參數(shù)之一是您也模擬的方法的結(jié)果,那么 Mockito 會感到不安.也許這是一種避免無限循環(huán)的重入檢查,我不知道.

                  For some reason, Mockito gets upset if one of the arguments you pass to the stub used with doThrow in this way is the result of a method you also mocked. Perhaps it's a re-entrancy check of sorts to avoid infinite loops, I don't know.

                  無論如何,嘗試將 sample.getId() 替換為常量值,這應(yīng)該可以解決問題.您可以考慮使用在測試中聲明的常量來進行模擬和任何進一步的使用.然后,您還可以通過添加另一個對 verify 的調(diào)用來檢查您正在測試的方法是否使用了 sample.getId().

                  Regardless, try replacing sample.getId() with a constant value and that should solve the issue. You could consider using a constant declared in your test for both the mock and any further uses of it. You could then also check that sample.getId() was used by the method you're testing by adding another call to verify.

                  這篇關(guān)于doThrow 中看起來正確的 Mockito 異常的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)

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

                      1. <legend id='cWQUY'><style id='cWQUY'><dir id='cWQUY'><q id='cWQUY'></q></dir></style></legend>

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

                          <tfoot id='cWQUY'></tfoot>
                            <tbody id='cWQUY'></tbody>

                            主站蜘蛛池模板: 能看的av| 超碰免费在 | 日韩高清一区 | 亚洲区一区二 | 欧美一级二级视频 | 欧美日韩不卡 | 久久99精品视频 | 神马九九 | 国产精品日产欧美久久久久 | 日韩亚洲视频在线 | 男女av| 亚洲精品乱码久久久久久蜜桃 | 中文字幕一区二区三区精彩视频 | 亚洲精品9999 | 中文字幕在线第一页 | 免费v片| 日韩在线视频一区 | 亚洲www啪成人一区二区 | 国产h视频 | 一区二区三区在线看 | avav在线看| 91视频一88av | 日韩二区| 精品入口麻豆88视频 | 一区中文 | 91av视频在线 | 国产ts人妖系列高潮 | 五月婷亚洲 | 中文一区二区视频 | 日本特黄a级高清免费大片 特黄色一级毛片 | 极品粉嫩国产48尤物在线播放 | 国产精品s色 | 久久精品美女 | 久久久久资源 | 精品三级 | 国产免费让你躁在线视频 | 精品一区二区三区在线视频 | 天天视频一区二区三区 | 精品亚洲一区二区三区四区五区高 | 久草资源在线 | 麻豆久久久久久 |