pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  1. <tfoot id='4NlXv'></tfoot>

    1. <small id='4NlXv'></small><noframes id='4NlXv'>

    2. <i id='4NlXv'><tr id='4NlXv'><dt id='4NlXv'><q id='4NlXv'><span id='4NlXv'><b id='4NlXv'><form id='4NlXv'><ins id='4NlXv'></ins><ul id='4NlXv'></ul><sub id='4NlXv'></sub></form><legend id='4NlXv'></legend><bdo id='4NlXv'><pre id='4NlXv'><center id='4NlXv'></center></pre></bdo></b><th id='4NlXv'></th></span></q></dt></tr></i><div class="jt83a3h" id='4NlXv'><tfoot id='4NlXv'></tfoot><dl id='4NlXv'><fieldset id='4NlXv'></fieldset></dl></div>
      <legend id='4NlXv'><style id='4NlXv'><dir id='4NlXv'><q id='4NlXv'></q></dir></style></legend>
        <bdo id='4NlXv'></bdo><ul id='4NlXv'></ul>

      Mockito's Matcher vs Hamcrest Matcher?

      Mockito#39;s Matcher vs Hamcrest Matcher?(Mockitos Matcher vs Hamcrest Matcher?)

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

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

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

            • <bdo id='pB3eV'></bdo><ul id='pB3eV'></ul>

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

                問(wèn)題描述

                這將是一個(gè)簡(jiǎn)單的問(wèn)題,但如果我的類路徑中包含兩個(gè)庫(kù),我找不到它們之間的區(qū)別以及使用哪一個(gè)?

                That's going to be an easy one, but I cannot find the difference between them and which one to use, if I have both the lib's included in my classpath?

                推薦答案

                Hamcrest 匹配器方法返回 Matcher 并且 Mockito 匹配器返回 T.因此,例如:org.hamcrest.Matchers.any(Integer.class) 返回 org.hamcrest.Matcher 的實(shí)例,以及 org.mockito.Matchers.any(Integer.class)code> 返回 Integer 的一個(gè)實(shí)例.

                Hamcrest matcher methods return Matcher<T> and Mockito matchers return T. So, for example: org.hamcrest.Matchers.any(Integer.class) returns an instance of org.hamcrest.Matcher<Integer>, and org.mockito.Matchers.any(Integer.class) returns an instance of Integer.

                這意味著您只能在簽名中需要 Matcher 對(duì)象時(shí)使用 Hamcrest 匹配器 - 通常是在 assertThat 調(diào)用中.在調(diào)用模擬對(duì)象的方法的地方設(shè)置期望或驗(yàn)證時(shí),您可以使用 Mockito 匹配器.

                That means that you can only use Hamcrest matchers when a Matcher<?> object is expected in the signature - typically, in assertThat calls. When setting up expectations or verifications where you are calling methods of the mock object, you use the Mockito matchers.

                例如(為了清楚起見(jiàn),使用完全限定的名稱):

                For example (with fully qualified names for clarity):

                @Test
                public void testGetDelegatedBarByIndex() {
                    Foo mockFoo = mock(Foo.class);
                    // inject our mock
                    objectUnderTest.setFoo(mockFoo);
                    Bar mockBar = mock(Bar.class);
                    when(mockFoo.getBarByIndex(org.mockito.Matchers.any(Integer.class))).
                        thenReturn(mockBar);
                
                    Bar actualBar = objectUnderTest.getDelegatedBarByIndex(1);
                
                    assertThat(actualBar, org.hamcrest.Matchers.any(Bar.class));
                    verify(mockFoo).getBarByIndex(org.mockito.Matchers.any(Integer.class));
                }
                

                如果您想在需要 Mockito 匹配器的上下文中使用 Hamcrest 匹配器,您可以使用 org.mockito.Matchers.argThat 匹配器.它將 Hamcrest 匹配器轉(zhuǎn)換為 Mockito 匹配器.因此,假設(shè)您想以某種精度(但不多)匹配雙精度值.在這種情況下,您可以這樣做:

                If you want to use a Hamcrest matcher in a context that requires a Mockito matcher, you can use the org.mockito.Matchers.argThat matcher. It converts a Hamcrest matcher into a Mockito matcher. So, say you wanted to match a double value with some precision (but not much). In that case, you could do:

                when(mockFoo.getBarByDouble(argThat(is(closeTo(1.0, 0.001))))).
                    thenReturn(mockBar);
                

                這篇關(guān)于Mockito's Matcher vs Hamcrest Matcher?的文章就介紹到這了,希望我們推薦的答案對(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='PpLAh'></bdo><ul id='PpLAh'></ul>

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

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

                        <legend id='PpLAh'><style id='PpLAh'><dir id='PpLAh'><q id='PpLAh'></q></dir></style></legend>
                            <tbody id='PpLAh'></tbody>
                        1. 主站蜘蛛池模板: 舞台木地板厂家_体育运动木地板_室内篮球馆木地板_实木运动地板厂家_欧氏篮球地板推荐 | 皮带机-带式输送机价格-固定式胶带机生产厂家-河南坤威机械 | 大立教育官网-一级建造师培训-二级建造师培训-造价工程师-安全工程师-监理工程师考试培训 | 旋振筛_不锈钢旋振筛_气旋筛_旋振筛厂家—新乡市大汉振动机械有限公司 | 山东钢格板|栅格板生产厂家供应商-日照森亿钢格板有限公司 | 热处理温控箱,热处理控制箱厂家-吴江市兴达电热设备厂 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 假肢-假肢价格-假肢厂家-河南假肢-郑州市力康假肢矫形器有限公司 | 电子海图系统-电梯检验系统-智慧供热系统开发-商品房预售资金监管系统 | 中空玻璃生产线,玻璃加工设备,全自动封胶线,铝条折弯机,双组份打胶机,丁基胶/卧式/立式全自动涂布机,玻璃设备-山东昌盛数控设备有限公司 | 护腰带生产厂家_磁石_医用_热压护腰_登山护膝_背姿矫正带_保健护具_医疗护具-衡水港盛 | 托利多电子平台秤-高精度接线盒-托利多高精度电子秤|百科 | 高空重型升降平台_高空液压举升平台_高空作业平台_移动式升降机-河南华鹰机械设备有限公司 | 焊管生产线_焊管机组_轧辊模具_焊管设备_焊管设备厂家_石家庄翔昱机械 | 铝镁锰板_铝镁锰合金板_铝镁锰板厂家_铝镁锰金属屋面板_安徽建科 | AR开发公司_AR增强现实_AR工业_AR巡检|上海集英科技 | 亚洲工业智能制造领域专业门户网站 - 亚洲自动化与机器人网 | 润东方环保空调,冷风机,厂房车间降温设备-20年深圳环保空调生产厂家 | 天津次氯酸钠酸钙溶液-天津氢氧化钠厂家-天津市辅仁化工有限公司 | 连续密炼机_双转子连续密炼机_连续式密炼机-南京永睿机械制造有限公司 | 逗网红-抖音网红-快手网红-各大平台网红物品导航 | 电杆荷载挠度测试仪-电杆荷载位移-管桩测试仪-北京绿野创能机电设备有限公司 | 爱科技iMobile-专业的科技资讯信息分享网站 | 信阳网站建设专家-信阳时代网联-【信阳网站建设百度推广优质服务提供商】信阳网站建设|信阳网络公司|信阳网络营销推广 | 螺旋压榨机-刮泥机-潜水搅拌机-电动泥斗-潜水推流器-南京格林兰环保设备有限公司 | 恒压供水控制柜|无负压|一体化泵站控制柜|PLC远程调试|MCGS触摸屏|自动控制方案-联致自控设备 | 宜兴紫砂壶知识分享 - 宜兴壶人 医用空气消毒机-医用管路消毒机-工作服消毒柜-成都三康王 | 桁架楼承板-钢筋桁架楼承板-江苏众力达钢筋楼承板厂 | 中央空调维修、中央空调保养、螺杆压缩机维修-苏州东菱空调 | Dataforth隔离信号调理模块-信号放大模块-加速度振动传感器-北京康泰电子有限公司 | 婚博会2024时间表_婚博会门票领取_婚博会地址-婚博会官网 | 食药成分检测_调料配方还原_洗涤剂化学成分分析_饲料_百检信息科技有限公司 | 卷筒电缆-拖链电缆-特种柔性扁平电缆定制厂家「上海缆胜」 | 济南品牌包装设计公司_济南VI标志设计公司_山东锐尚文化传播 | 顶呱呱交易平台-行业领先的公司资产交易服务平台 | 福建成考网-福建成人高考网 | 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 | 浇注料-高铝砖耐火砖-郑州凯瑞得窑炉耐火材料有限公司 | 户外健身路径_小区健身器材_室外健身器材厂家_价格-浩然体育 | 生物风-销售载体,基因,质粒,ATCC细胞,ATCC菌株等,欢迎购买-百风生物 | 考勤系统_考勤管理系统_网络考勤软件_政企|集团|工厂复杂考勤工时统计排班管理系统_天时考勤 |