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

jmock 模擬靜態(tài)方法

jmock mocking a static method(jmock 模擬靜態(tài)方法)
本文介紹了jmock 模擬靜態(tài)方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的代碼中有一個靜態(tài)方法,我想以某種方式模擬.

I have a static method in my code that I would like somehow to mock.

我正在使用 jmock.

I am using jmock.

我想我可以做到這一點的一種方法是在靜態(tài)方法周圍設置包裝類",然后模擬這個,但我希望有更好的解決方案.

One way I suppose I could do this is to have "wrapper class" around the static method and mock this but I was hoping for a better solution.

我想錯了嗎?

反饋:

我將擁有一個接口和類,其中包含一個調(diào)用靜態(tài)方法的方法.它允許我通過模擬對這個包裝類的調(diào)用來模擬邏輯.(說起來我都覺得很臟:))

I was going to have a interface and class that had a method that just called the static method. It would allow me to mock the logic by just mocking the call to this wrapper class. (I feel dirty even talking about it :) )

推薦答案

我們不支持在 jMock 中模擬靜態(tài)方法,因為它不適合我們的設計方法.對于可能影響系統(tǒng)狀態(tài)的重要功能,我們不喜歡使用靜態(tài)方法.我們傾向于使用它們只是為了支持 OO 代碼并使其更具可讀性.這就是為什么我們將模擬靜態(tài)方法視為存在問題的暗示.一個例外是它位于第三方庫中,但無論如何我們可能會將其包裝在更面向?qū)ο蟮臇|西中.

We don't support mocking static methods in jMock because it doesn't fit our design approach. We prefer not to use static methods for significant features that can affect the state of the system. We tend to use them just to support the OO code and make it more readable. That's why we view mocking a static methods as a hint that there's a problem. One exception is where it's in a third-party library, but we would probably wrap that in something more object-oriented anyway.

這篇關于jmock 模擬靜態(tài)方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

How to mock super reference (on super class)?(如何模擬超級參考(在超級類上)?)
Java mock database connection(Java 模擬數(shù)據(jù)庫連接)
Mockito ClassCastException - A mock cannot be cast(Mockito ClassCastException - 無法投射模擬)
Set value to mocked object but get null(將值設置為模擬對象但獲取 null)
How to mock DriverManager.getConnection(...)?(如何模擬 DriverManager.getConnection(...)?)
Mockito; verify method was called with list, ignore order of elements in list(模擬;使用列表調(diào)用驗證方法,忽略列表中元素的順序)
主站蜘蛛池模板: 成人不卡| 成人欧美一区二区三区黑人孕妇 | 在线日韩视频 | 中文字幕不卡在线观看 | 久久久久国产一区二区三区四区 | 夜夜骑首页| 国产欧美精品一区二区色综合朱莉 | 国产男女猛烈无遮掩视频免费网站 | 精品国产一区二区三区成人影院 | 欧美日韩免费在线 | 精精国产xxxx视频在线野外 | 亚洲 欧美 另类 综合 偷拍 | 别c我啊嗯国产av一毛片 | 区一区二区三在线观看 | 久久人人爽人人爽人人片av免费 | 精品一区二区久久久久久久网精 | 国产精品久久久久9999鸭 | 一区二区精品视频 | 91pron在线| 久久99这里只有精品 | 99久久久久久久久 | 99久久免费精品 | 欧美va大片 | 国产精品美女 | 亚洲午夜av久久乱码 | 国产精品成人久久久久a级 久久蜜桃av一区二区天堂 | 亚洲视频在线观看 | 日韩欧美国产精品一区二区三区 | 欧美一区成人 | 91 在线| 午夜视频在线视频 | a在线免费观看视频 | 99精品久久| 成人精品久久 | 色婷婷影院 | 亚洲精品68久久久一区 | 免费在线看黄 | 亚洲激情一级片 | 成人免费视频一区二区 | 免费久久网 | 日韩播放 |