| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| .github/ | 04-Jul-2025 | - | 113 | 72 | ||
| .idea/ | 04-Jul-2025 | - | 300 | 300 | ||
| gradle/ | 04-Jul-2025 | - | 76 | 60 | ||
| mockito-kotlin/ | 04-Jul-2025 | - | 2,210 | 1,034 | ||
| ops/ | 04-Jul-2025 | - | 13 | 7 | ||
| tests/ | 04-Jul-2025 | - | 2,314 | 1,514 | ||
| .gitignore | D | 04-Jul-2025 | 153 | 14 | 10 | |
| Android.bp | D | 04-Jul-2025 | 2.3 KiB | 77 | 67 | |
| LICENSE | D | 04-Jul-2025 | 1.1 KiB | 22 | 18 | |
| METADATA | D | 04-Jul-2025 | 520 | 20 | 18 | |
| MODULE_LICENSE_MIT | D | 04-Jul-2025 | 0 | |||
| OWNERS | D | 04-Jul-2025 | 108 | 4 | 3 | |
| README.md | D | 04-Jul-2025 | 2.3 KiB | 68 | 46 | |
| RELEASING.md | D | 04-Jul-2025 | 656 | 13 | 11 | |
| build.gradle | D | 04-Jul-2025 | 2.8 KiB | 83 | 73 | |
| gradle.properties | D | 04-Jul-2025 | 16 | 2 | 1 | |
| gradlew | D | 04-Jul-2025 | 5.6 KiB | 186 | 125 | |
| gradlew.bat | D | 04-Jul-2025 | 2.7 KiB | 90 | 68 | |
| settings.gradle | D | 04-Jul-2025 | 40 | 2 | 2 | |
| version.properties | D | 04-Jul-2025 | 11 | 2 | 1 |
README.md
1# Mockito-Kotlin 2[  ](https://maven-badges.herokuapp.com/maven-central/org.mockito.kotlin/mockito-kotlin) 3[](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