官术网_书友最值得收藏!

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 the hamcrest and objenesis libraries—as of June 2011).
  • mockito-core: This is only Mockito core (without hamcrest or objenesis). Use this if you want to control which version of hamcrest or objenesis 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

主站蜘蛛池模板: 渝北区| 林州市| 呼和浩特市| 崇阳县| 江门市| 平山县| 静宁县| 高陵县| 六盘水市| 临夏县| 吉隆县| 兰考县| 调兵山市| 邢台县| 堆龙德庆县| 庆城县| 江西省| 碌曲县| 寿宁县| 望谟县| 营口市| 沐川县| 花莲县| 淳安县| 蓬安县| 兴义市| 资源县| 裕民县| 乌兰察布市| 株洲县| 威远县| 丰城市| 遵义县| 无极县| 精河县| 保定市| 万全县| 林西县| 阜康市| 博乐市| 建水县|