- Test-Driven Java Development(Second Edition)
- Alex Garcia Viktor Farcic
- 136字
- 2021-06-24 18:31:49
Extra power for mocks
Both projects introduced earlier do not cover all types of methods or fields. Depending on the applied modifiers, such as static or final, a class, method, or field, can be out of range for Mockito or EasyMock. In such cases, we can use PowerMock to extend the mocking framework. This way, we can mock objects that can only be mocked in a tricky manner. However, one should be cautious with PowerMock since the necessity to use many of the features it provides is usually a sign of poor design. If you're working on a legacy code, PowerMock might be a good choice. Otherwise, try to design your code in such a way that PowerMock is not needed. We'll show you how to do that later on.
For more information, visit https://code.google.com/p/powermock/.
推薦閱讀
- Embedded Linux Projects Using Yocto Project Cookbook
- DevOps with Kubernetes
- Spring 5企業級開發實戰
- Java EE 6 企業級應用開發教程
- Ext JS Data-driven Application Design
- Apex Design Patterns
- Python數據可視化之Matplotlib與Pyecharts實戰
- Android程序設計基礎
- Natural Language Processing with Python Quick Start Guide
- 分布式數據庫原理、架構與實踐
- Building Slack Bots
- MongoDB Cookbook(Second Edition)
- scikit-learn Cookbook(Second Edition)
- LabVIEW數據采集
- Java并發實現原理:JDK源碼剖析