• Home
Name Date Size #Lines LOC

..--

.github/04-Jul-2025-11372

.idea/04-Jul-2025-300300

gradle/04-Jul-2025-7660

mockito-kotlin/04-Jul-2025-2,2101,034

ops/04-Jul-2025-137

tests/04-Jul-2025-2,3141,514

.gitignoreD04-Jul-2025153 1410

Android.bpD04-Jul-20252.3 KiB7767

LICENSED04-Jul-20251.1 KiB2218

METADATAD04-Jul-2025520 2018

MODULE_LICENSE_MITD04-Jul-20250

OWNERSD04-Jul-2025108 43

README.mdD04-Jul-20252.3 KiB6846

RELEASING.mdD04-Jul-2025656 1311

build.gradleD04-Jul-20252.8 KiB8373

gradle.propertiesD04-Jul-202516 21

gradlewD04-Jul-20255.6 KiB186125

gradlew.batD04-Jul-20252.7 KiB9068

settings.gradleD04-Jul-202540 22

version.propertiesD04-Jul-202511 21

README.md

1# Mockito-Kotlin
2[ ![Download](https://maven-badges.herokuapp.com/maven-central/org.mockito.kotlin/mockito-kotlin/badge.svg) ](https://maven-badges.herokuapp.com/maven-central/org.mockito.kotlin/mockito-kotlin)
3[![Nexus Snapshot](https://img.shields.io/nexus/s/org.mockito.kotlin/mockito-kotlin?server=https%3A%2F%2Fs01.oss.sonatype.org%2F)](https://s01.oss.sonatype.org/content/repositories/snapshots/org/mockito/kotlin/mockito-kotlin/)
4
5A small library that provides helper functions to work with [Mockito](https://github.com/mockito/mockito) in Kotlin.
6
7## Install
8
9Mockito-Kotlin is available on Maven Central.
10For Gradle users, add the following to your `build.gradle`, replacing `x.x.x` with the latest version:
11
12```groovy
13testImplementation "org.mockito.kotlin:mockito-kotlin:x.x.x"
14```
15
16## Example
17
18A test using Mockito-Kotlin typically looks like the following:
19
20```kotlin
21@Test
22fun doAction_doesSomething(){
23  /* Given */
24  val mock = mock<MyClass> {
25    on { getText() } doReturn "text"
26  }
27  val classUnderTest = ClassUnderTest(mock)
28
29  /* When */
30  classUnderTest.doAction()
31
32  /* Then */
33  verify(mock).doSomething(any())
34}
35```
36
37For more info and samples, see the [Wiki](https://github.com/mockito/mockito-kotlin/wiki).
38
39## Building
40
41Mockito-Kotlin is built with Gradle.
42
43 - `./gradlew build` builds and tests the project
44 - `./gradlew publishToMavenLocal` installs the maven artifacts in your local repository
45 - `./gradlew check` runs the test suite (See Testing below)
46
47### Versioning
48
49Mockito-Kotlin roughly follows SEMVER
50
51### Testing
52
53Mockito-Kotlin's test suite is located in a separate `tests` module,
54to allow running the tests using several Kotlin versions whilst still
55keeping the base module at a recent version.
56
57 - `./gradlew check` runs the checks including tests.
58
59Usually it is enough to test only using the default Kotlin versions;
60CI will test against multiple versions.
61If you want to test using a different Kotlin version locally, set
62an environment variable `KOTLIN_VERSION` and run the tests.
63
64### Acknowledgements
65
66`mockito-kotlin` was created and developed by [nhaarman@](https://github.com/nhaarman) after which the repository was integrated into the official Mockito GitHub organization.
67We would like to thank Niek for the original idea and extensive work plus support that went into `mockito-kotlin`.
68