- Mockito Cookbook
- Marcin Grzejszczak
- 269字
- 2021-07-16 11:34:59
Adding Mockito to a project's classpath
Adding Mockito to a project's classpath is as simple as adding one of the two jars to your project's classpath:
mockito-all
: This is a single jar with all dependencies (with thehamcrest
andobjenesis
libraries—as of June 2011).mockito-core
: This is only Mockito core (withouthamcrest
orobjenesis
). Use this if you want to control which version ofhamcrest
orobjenesis
is used.
How to do it...
If you are using a dependency manager that connects to the Maven Central Repository, then you can get your dependencies as follows (examples of how to add mockito-all
to your classpath for Maven and Gradle):
For Maven, use the following code:
<dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.9.5</version> <scope>test</scope> </dependency>
For Gradle, use the following code:
testCompile "org.mockito:mockito-all:1.9.5"
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
If you are not using any of the dependency managers, you have to either download mockito-all.jar
or mockito-core.jar
and add it to your classpath manually (you can download the jars from https://code.google.com/p/mockito/downloads/list). To see more examples of adding Mockito to your classpath, please check the book, Instant Mockito, Marcin Grzejszczak, Packt Publishing, for more examples of adding Mockito to your classpath (it includes Ant, Buildr, Sbt, Ivy, Gradle, and Maven).
See also
- Refer to Instant Mockito, Marcin Grzejszczak, Packt Publishing for an introduction to Mockito together with examples of Mockito configuration in several build tools at http://www.packtpub.com/how-to-create-stubs-mocks-spies-using-mockito/book
- Mastering Ninject for Dependency Injection
- 數據庫應用基礎教程(Visual FoxPro 9.0)
- 數據驅動:從方法到實踐
- Creating Dynamic UIs with Android Fragments(Second Edition)
- SQL優化最佳實踐:構建高效率Oracle數據庫的方法與技巧
- 深入淺出Greenplum分布式數據庫:原理、架構和代碼分析
- Proxmox VE超融合集群實踐真傳
- 高維數據分析預處理技術
- INSTANT Android Fragmentation Management How-to
- SIEMENS數控技術應用工程師:SINUMERIK 840D-810D數控系統功能應用與維修調整教程
- 智慧城市中的大數據分析技術
- Hands-On System Programming with C++
- 數據庫原理與設計實驗教程(MySQL版)
- 云計算
- 數據分析思維:產品經理的成長筆記