Kotest
Powerful, elegant and flexible test framework for Kotlin with assertions, property testing and data driven tests. (by kotest)
mockk
mocking library for Kotlin (by mockk)
Kotest | mockk | |
---|---|---|
17 | 17 | |
4,466 | 5,454 | |
0.6% | 0.4% | |
9.7 | 8.6 | |
1 day ago | about 2 months ago | |
Kotlin | Kotlin | |
Apache License 2.0 | Apache License 2.0 |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Kotest
Posts with mentions or reviews of Kotest.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2023-11-29.
-
AocKt: Test-driven Advent of Code in Kotlin
As you might know, Advent of Code will begin this Friday! If, like me, you want to have a go at solving the puzzles in Kotlin, I would like to share with you a little library I've developed to reduce boilerplate and solve the puzzles in a test-driven approach. It is based on Kotest, a modern and Kotlin-first test framework.
-
Tests Everywhere - Kotlin
Kotlin testing with Kotest and MockK
-
Best practices for Unit Testing Android Apps with Mockk, Kotest and others
As a matter of fact, in the previous examples, we have shifted a bit away from the TDD standards in the meaning that we test not only the operability of our code, but rather check if the code runs according to certain specifications (Given/When/Then). These specifications are our tests, and the syntactic sugar in the form of the possibility to give clear names to the tests using DisplayName and the grouping of the tests by a set of similar attributes helps us clearly formulate these specifications. There is an entire family of frameworks in different languages that allow us to create such specifications: for Java it is Spock, for Ruby—RSpec, and for Kotlin—Spek and Kotest frameworks. Below, I will go into more detail about them.
- Why do Kotlin tests (for Gradle projects) have to be inside classes?
-
Kotlin Mutation Tests
I've tried so many times. SO MANY. I love the idea of mutation testing. Even chatGPT couldn't help me. It just made up fake mutation testing frameworks to try. To me, pitest is dead. kotest is not mutation testing, but it's property testing is the next best thing I have found to revolutionize your unit tests.
-
How to improve third-party libraries with Kotlin extensions
The extensions are not particularly useful in this scenario because the described functionality can be incorporated into the Host class. On the other hand, they flourish in test frameworks like Kotest and enable the rapid development of useful add-ons like custom matchers. Extending third-party libraries with utility functions is another prevalent use case. In the next sections, we'll zero in on this specific aspect.
- Are there any plans to make a better build system for Kotlin than Gradle?
-
Testing with fakes different states?
We're using Kotest for our unit tests and are quite happy with it.
-
Testing with Kotlin and JUnit5
Basic testing in Kotlin with Kotest built for kotlin specificatlly (upcoming)
-
Kotlin&Junit vs Groovy&Spock
Here you are: https://github.com/kotest/kotest/issues/189
mockk
Posts with mentions or reviews of mockk.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2023-11-23.
-
For those DAO, Services, how about using static objects with mockk for test
The official suggests using dagger/hilt to inject them. However, they could be static based on the static ApplicationContext. Although Dagger/hilt aids in unit testing, mockk can accomplish this easily as well by modifying bytecode during run time. As for the stability, `mockk` has 5000+ stars on GitHub and keeps renewing.
-
Tests Everywhere - Kotlin
We can create it as a class as MockK is able to mock final classes.
-
🧪 **Demystifying Kotlin Unit Testing**: Your Odyssey to Code Confidence! 🚀
Mockk Documentation
-
Best practices for Unit Testing Android Apps with Mockk, Kotest and others
Mockk is a rather new framework; it was originally designed for Kotlin, although it supports Java as well. Before mockito-kotlin was released, using Mockk was much easier and beneficial for Kotlin developers, but right now both these frameworks have nearly the same set of features and similar syntax. For example, assume that our function loadUsers is no longer synchronous, but rather suspended:
-
LocalDateTime.now() mockk
You can use mockkStatic for that, see docs. Also don't forget to unmockkStatic afterwards.
-
reflective-mockk: Stub methods programmatically using kotlin-reflect
WARNING: reflective-mockk is currently powered by a reflective “hack” on mockK, and is thereby subject to removal/breakage by the mockK team at any time. If you enjoy this library & want it to be officially supported, post a comment saying so on this PR: https://github.com/mockk/mockk/pull/1005.
-
mockk VS mockative - a user suggested alternative
2 projects | 9 Nov 2022
- Are there any plans to make a better build system for Kotlin than Gradle?
-
Spring with java vs Spring with kotlin
https://mockk.io/ is great, too.
-
From Java to Kotlin. There and back again
Mockito does not work correctly with Kotlin types out of the box. Spring recommends using Mockk. There is also a special module for Mockito, which adds support for Kotlin - Mockito-Kotlin.
What are some alternatives?
When comparing Kotest and mockk you can also consider the following projects:
spek - A specification framework for Kotlin
mockito-kotlin - Using Mockito with Kotlin
Kluent - Fluent Assertion-Library for Kotlin
strikt - An assertion library for Kotlin
mock-fuel - JUnit 5 extension to easily test with the http client Fuel for Kotlin
hamkrest - Hamcrest for Kotlin
kotlin-logging - Lightweight Multiplatform logging framework for Kotlin. A convenient and performant logging facade.
atrium - A multiplatform expectation library for Kotlin
expekt - BDD assertion library for Kotlin