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

在集成測試中進行模擬是否被認為是一種好習慣

Is it in considered a good practice to mock in integration test?(在集成測試中進行模擬是否被認為是一種好習慣?)
本文介紹了在集成測試中進行模擬是否被認為是一種好習慣?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

有人告訴我@Mock 通常只用于單元測試,但我認為它對于替換測試類之外的外部部分很有用.在集成測試中模擬是否正確?

Somebody told me @Mock is usually employed only for unit tests but I think is useful for substituting the external parts outside the tested class. Is it correct to mock in integration tests?

推薦答案

最后,這都是關于措辭的.

In the end, this is all about wording.

當您從最基本的意義上考慮正確"時,例如 正確性,那么答案很簡單:沒有.

When you think of "correct" in its very fundamental sense, as in correctness, then the answer is simply: no.

您知道,集成測試的目標是確保您的集成系統(由多個不同的組件組成)按預期運行.集成測試的目的是驗證您的組件管道"是否按預期工作.因此:當系統的部分被模擬出來時,您無法驗證您的系統是否正常工作.

You see, the goal of an integration test is to ensure that your integrated system (consisting of multiple, different components) functions as expected. The purpose of an integration test is to verify that your "plumbing" of components works as expected. Therefore: you can't verify that your system works when parts of that system are mocked out.

但是,您可以不那么嚴格地考慮正確性".

But then, you can think "correctness" less strictly.

示例:銷售汽車的公司必須測試 ECU.基本上是一個硬件,運行一個潛在的巨大軟件堆棧.這些 ECU 通常在 汽車 內運行.所以當你想對一個ECU進行集成測試時,你必須把ECU放到汽車中進行測試,對吧?一輛可能還不存在的汽車.這里的解決方案:有硬件模擬器.您將 ECU 插入該仿真器,然后 ECU 會思考"位于真車內的內容.

Example: companies selling cars have to test ECUs. Basically a piece of hardware, running a potentially huge software stack. These ECUs normally operate within cars. So when you want to integration test an ECU, you would have to put the ECU into a car for testing, right? A car that probably doesn't exist yet. The solution here: there are hardware emulators. You plug the ECU into that emulator, and the ECU "thinks" that sits inside a real car.

所以:有很好的論據聲稱真正的集成測試不能使用模擬",但與此同時,在現實世界中,這種模擬"一直在發生.

So: there are good arguments to claim "a true integration test can't use mocking", but at the same time, in the real world, such "mocking" happens all the time.

因此,真正的答案是:這取決于上下文.因此,沒有一個普遍的答案.相反,這是關于溝通.您只需"確保您的組/組織中的所有人都對這些術語有相同的理解.

The real answer is therefore: it depends on context. Therefore there isn't a universal answer. Instead, this is about communication. You "simply" have to ensure that all people in your group/org have the same understanding of such terms.

這個詞本身可以用不同的方式來解釋.您(共同!)選擇最適合您需求的定義,然后確保所有為您的項目做出貢獻的人都共享該觀點(或至少了解它).

The term itself can be interpreted in different ways. You (jointly!) pick that definition that best fits your needs, to then make sure all people contributing to your project share that view (or at least know about it).

這篇關于在集成測試中進行模擬是否被認為是一種好習慣?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

How to mock super reference (on super class)?(如何模擬超級參考(在超級類上)?)
Java mock database connection(Java 模擬數據庫連接)
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(模擬;使用列表調用驗證方法,忽略列表中元素的順序)
主站蜘蛛池模板: 亚洲欧美在线免费观看 | 免费久久久久久 | 欧美国产91| 日韩电影一区二区三区 | 亚洲二区精品 | 久久久久久久久99 | 在线观看涩涩视频 | 午夜精品在线观看 | 亚洲精品一区中文字幕 | 精产国产伦理一二三区 | 免费天天干 | 久久久精品高清 | 日韩免费视频一区二区 | 在线视频日韩 | 精品国产精品 | 91伊人网| 久久国产精品72免费观看 | 国产成人精品一区二 | 99精品国自产在线 | 视频一区在线 | 一级二级三级在线观看 | 欧美色综合一区二区三区 | 午夜影院在线观看免费 | 日韩欧美中文字幕在线观看 | 国产精品一区二区久久久久 | 精品乱码一区二区三四区视频 | 欧美一级一 | 99久久婷婷国产综合精品电影 | 国产91丝袜在线18 | 草草视频在线免费观看 | 日本成人一区二区 | 欧美一级淫片免费视频黄 | 国产精品久久久久久久久免费软件 | 中文字幕11页 | 国产精品国产三级国产aⅴ中文 | 亚洲国产精品一区二区久久 | 一级欧美一级日韩片免费观看 | 亚洲人成免费 | 久久99精品国产自在现线小黄鸭 | 91精品国产91久久久久游泳池 | 精品亚洲一区二区三区 |