久久久久久久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 中看起來(lái)正確的 Mockito 異常

        Mockito exception in doThrow that looks correct(doThrow 中看起來(lái)正確的 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 中看起來(lái)正確的 Mockito 異常的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在嘗試模擬一個(gè)方法以查看我是否正確處理了異常.這是據(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;
                      // ...
                  }
                  

                  單元測(cè)試:

                  // ...
                  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.
                  

                  推薦答案

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

                  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ì)感到不安.也許這是一種避免無(wú)限循環(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.

                  無(wú)論如何,嘗試將 sample.getId() 替換為常量值,這應(yīng)該可以解決問(wèn)題.您可以考慮使用在測(cè)試中聲明的常量來(lái)進(jìn)行模擬和任何進(jìn)一步的使用.然后,您還可以通過(guò)添加另一個(gè)對(duì) verify 的調(diào)用來(lái)檢查您正在測(cè)試的方法是否使用了 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 中看起來(lái)正確的 Mockito 異常的文章就介紹到這了,希望我們推薦的答案對(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?)

                    <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>

                            主站蜘蛛池模板: 精品三区 | 韩国主播午夜大尺度福利 | 亚洲综合三区 | 开操网| 久久99精品国产自在现线小黄鸭 | 欧美成人h版在线观看 | 九九久久国产 | 亚洲一区免费视频 | 91亚洲国产成人久久精品网站 | 中文字幕一区二区三区四区不卡 | 久草热8精品视频在线观看 午夜伦4480yy私人影院 | 国产伦精品一区二区三区精品视频 | 激情欧美日韩一区二区 | 午夜久久久久久久久久一区二区 | 国产精品久久久久久久久免费相片 | 国产美女精品视频免费观看 | 亚洲精品一区在线观看 | 天天射网站 | 亚洲精品国产a久久久久久 中文字幕一区二区三区四区五区 | 国产亚洲精品久久久优势 | 欧洲免费视频 | 在线免费观看欧美 | 欧美精品在线免费观看 | 欧美最猛黑人 | 91免费在线视频 | 日韩成人影院在线观看 | 精品粉嫩aⅴ一区二区三区四区 | 国产精品亚洲精品 | 日韩欧美综合在线视频 | 国产精品视频免费看 | 国产日韩欧美精品一区二区三区 | 国产三区视频在线观看 | 免费久久网 | av大片在线 | 亚洲国产精品一区二区第一页 | 国产午夜精品久久久久 | 久久综合一区 | 一级毛片免费 | 精品国产欧美一区二区 | 成人午夜黄色 | 日韩精品一区二区三区中文在线 |