Android 16.0.0 release 1
Snap for 13235988 from e0d6d2d1352beec9d4456d4182b0a7ff67983532 to 25Q2-release

Change-Id: I7ea21fb39507795f7312983143db5a144f0e851d
tree: 7c2df5315daf377ab953c55e3e7fca1999841a82
  1. .github/
  2. .idea/
  3. gradle/
  4. mockito-kotlin/
  5. ops/
  6. tests/
  7. .gitignore
  8. Android.bp
  9. build.gradle
  10. gradle.properties
  11. gradlew
  12. gradlew.bat
  13. LICENSE
  14. METADATA
  15. MODULE_LICENSE_MIT
  16. OWNERS
  17. README.md
  18. RELEASING.md
  19. settings.gradle
  20. version.properties
README.md

Mockito-Kotlin

Download Nexus Snapshot

A small library that provides helper functions to work with Mockito in Kotlin.

Install

Mockito-Kotlin is available on Maven Central. For Gradle users, add the following to your build.gradle, replacing x.x.x with the latest version:

testImplementation "org.mockito.kotlin:mockito-kotlin:x.x.x"

Example

A test using Mockito-Kotlin typically looks like the following:

@Test
fun doAction_doesSomething(){ 
  /* Given */
  val mock = mock<MyClass> {
    on { getText() } doReturn "text"
  }
  val classUnderTest = ClassUnderTest(mock)
  
  /* When */
  classUnderTest.doAction()
  
  /* Then */
  verify(mock).doSomething(any())
}

For more info and samples, see the Wiki.

Building

Mockito-Kotlin is built with Gradle.

  • ./gradlew build builds and tests the project
  • ./gradlew publishToMavenLocal installs the maven artifacts in your local repository
  • ./gradlew check runs the test suite (See Testing below)

Versioning

Mockito-Kotlin roughly follows SEMVER

Testing

Mockito-Kotlin's test suite is located in a separate tests module, to allow running the tests using several Kotlin versions whilst still keeping the base module at a recent version.

  • ./gradlew check runs the checks including tests.

Usually it is enough to test only using the default Kotlin versions; CI will test against multiple versions. If you want to test using a different Kotlin version locally, set an environment variable KOTLIN_VERSION and run the tests.

Acknowledgements

mockito-kotlin was created and developed by nhaarman@ after which the repository was integrated into the official Mockito GitHub organization. We would like to thank Niek for the original idea and extensive work plus support that went into mockito-kotlin.