本文介紹了如何使用 Mockito 模擬上下文?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在使用 Context 來訪問 WifiManager 和 BluetoothManager 等系統級服務.如何使用 Mockito 模擬這個 getApplicationContext()?
解決方案
我們來看看下面這個類:MockContext
如果您需要更深入的了解,請查看官方測試基礎頁面p>
I'm using Context to access system level services like WifiManager and BluetoothManager. How to mock this getApplicationContext() using Mockito?
解決方案
Let's have a look at the following class: MockContext
If you need more insight, check the Official Testing Fundamentals page
這篇關于如何使用 Mockito 模擬上下文?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!