mockito-kotlin alternatives and similar libraries
Based on the "Tests" category.
Alternatively, view mockito-kotlin alternatives based on common mentions on social networks and blogs.
-
Kotest
Powerful, elegant and flexible test framework for Kotlin with additional assertions, property testing and data driven testing -
kotlin-faker
https://serpro69.github.io/kotlin-faker/ Generate realistically looking fake data such as names, addresses, banking details, and many more, that can be used for testing and data anonymization purposes. -
hikaku
A library that tests if the implementation of a REST-API meets its specification. -
minutest
Simple, Expressive, Extensible Testing for Kotlin on the JVM -
balin
Balin is an automation library for Kotlin. It's basically a Selenium-WebDriver wrapper inspired by Geb. -
SeleniumBuilder
Kotlin DSL for Selenium. Provide a possibility to write tests in Kotlin type-safe builders style -
arbitrater
Arbitrater is a Kotlin library for creating arbitrary instances of classes by reflection for use in testing. In contrast to POJO generators, it supports Kotlin's optional parameters and nullable types. -
aspen
Aspen is a simple test runner for Kotlin that allows you to write tests using your own DSL. -
mock-fuel
JUnit 5 extension to easily test with the http client Fuel for Kotlin
Appwrite - The Open Source Firebase alternative introduces iOS support
Do you think we are missing an alternative of mockito-kotlin or a related project?
README
Mockito-Kotlin
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 [email protected] 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
.