Kotest: A Kotlin Testing Framework You'll Fall in Love With
Kotest is a feature-rich, handy, and modular testing framework built in Kotlin. Explore what it can do.
Kotest is a feature-rich, handy, and modular testing framework built in Kotlin.
In this article, I’ll take a much closer look at what Kotest can do. Expect plenty of hands-on examples and code snippets, so buckle up and get ready!
Kotest modules
Kotest is built from modules, and at the moment it has three main ones: Test Framework, Assertions Library, and Property Testing. You’re free to use all of them together, but you can just as well pick only those you need and combine them with other testing frameworks or libraries.
You could, for instance, use only Kotest Assertions inside your JUnit tests. Or you could write tests with the core Kotest Test Framework and rely on AssertJ for assertions. You might also want to combine Kotest with Spring Boot Tests, and that works smoothly too.
Kotest Test Framework
The Test Framework is Kotest’s central module. Kotest tests are flexible and can run on JVM, Javascript, and Native environments, which makes it a multi-platform testing framework. In this post, though, I’ll concentrate solely on the JVM.
Adding it to a Gradle project only requires declaring the dependency below and telling Gradle to run tests on the JUnit platform:
dependencies {
…
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
…
}
tasks.test {
useJUnitPlatform()
}
Testing styles
If I had to choose a single word that captures the Kotest framework best, it would certainly be flexibility. That’s largely due to how Kotest lets you write test cases. It gives you no fewer than ten different testing styles!
As a result, any developer picking up Kotest should feel comfortable whatever technology they come from, since each testing style draws on an existing programming language or testing framework.
For example, this is how a test case looks in the default testing style, called FunSpec:
class MyFunSpec: FunSpec({
test("2 plus 2 should be 4") {
(2 + 2) shouldBe 4
}
})
If BDD is more your thing, you can write the very same test case in another way with BehaviorSpec:
class MyBehaviorSpec: BehaviorSpec({
Given("Number 2") {
val num1 = 2
And("another number 2") {
val num2 = 2
When ("adding those numbers") {
val result = num1 + num2
Then("the result should be 4") {
result shouldBe 4
}
}
}
}
})
That’s only two out of the ten styles on offer. To get to know all of them, feel free to look at the official Kotest documentation, which describes every one of the testing styles.
Kotest vs JUnit
There’s one more thing I’d like to point out. Take a careful look at how Kotest defines test cases. In JUnit, test cases are function definitions, whereas in Kotest they’re function calls placed in the init block of a Spec class. In essence, Kotest gives us a DSL for writing tests. This seemingly minor detail unlocks a powerful feature: generating test cases dynamically at runtime.
For instance, we can write something like this:
class DynamicSpec : FunSpec({
for (i in 1..10) {
test("Test nr $i") {
i shouldBeGreaterThan 0
}
}
})
The example above produces 10 test cases, each with a name built dynamically. This particular example might not be very practical, but it demonstrates the idea well.
We can go a step further, though. Imagine our project has a src/test/resources/test_definitions directory containing .txt files whose content is laid out like this:
This is first test
2,2
4
We can then write a test suite that generates test cases on the fly from these files:
class DynamicSpec : FunSpec({
File("src/test/resources/test_definitions").walkTopDown()
.filter { it.name.endsWith(".txt") }
.forEach { testFile ->
val lines = testFile.readLines(Charsets.UTF_8)
val testName = lines[0]
val numbersToBeAdded = lines[1]
.split(",")
.map(String::toInt)
val expectedResult = lines[2].toInt()
// This will generate separate test case for each file in test_definitions directory
test(testName) {
numbersToBeAdded.reduce(Int::plus) shouldBe expectedResult
}
}
})
And just like that, we’ve built a dynamic test suite whose test cases come from external text files with custom content.
This is only one example, of course, and there are lots of creative ways to make use of this feature. Isn’t that awesome?!
Lifecycle Hooks and Extensions
Besides its various styles, Kotest also comes with a flexible mechanism of lifecycle hooks and extensions. It includes all the usual hooks familiar from other testing frameworks, like beforeSpec, afterSpec, beforeTest, afterTest, and so on. On top of that, we can easily write and plug in our own extensions and hooks.
Conditional Evaluation
Kotest offers powerful means of running tests conditionally. You have plenty of choices, from just switching off particular test cases to running only the ones that meet complex conditions checked at runtime. The example below shows what’s possible here:
test("This will never run").config(enabled = false) {
// test something here
}
test("This will only run on Linux").config(enabled = SystemUtils.IS_OS_LINUX) {
// test something here
}
fun isNight() = now().isAfter(LocalTime.of(20, 0)) || now().isBefore(LocalTime.of(8, 0))
test("This will run only nightly").config(enabledIf = { isNight() }) {
// test something here
}
Test Organization and Filtering
Kotest gives you several ways of structuring and filtering tests, which helps when handling large test suites and concentrating on particular parts of your codebase.
A central feature for structuring tests is the describe function of DescribeSpec, which lets you put related tests in one group. This helps you organize test code so that it mirrors the functionality under test, which makes it easier to read and maintain.
Below is an example of grouping tests with the describe function:
class MyDescribeSpec : DescribeSpec({
describe("Arithmetic operations") {
it("should add numbers correctly") {
(2 + 2) shouldBe 4
}
it("should subtract numbers correctly") {
(4 - 2) shouldBe 2
}
}
})
Apart from grouping, Kotest also lets you label and filter tests with tags. You can use tags to classify tests by things like functionality, priority, or environment. Based on these tags, you can then include or exclude tests from a run, which comes in especially handy in big projects with large test suites.
Here’s how tests can be tagged:
class MyTaggedSpec : FunSpec({
test("important test").config(tags = setOf(MyTags.Important)) {
// test code
}
test("optional test").config(tags = setOf(MyTags.Optional)) {
// test code
}
})
object MyTags {
val Important = Tag("Important")
val Optional = Tag("Optional")
}
To run just the important tests, use this command:
gradle test --tests * --include-tag Important
With the describe function and tags, you can organize and filter your tests efficiently, which makes them easier to manage and run whenever you need.
Coroutines Support
As you’d expect from a framework built in and for Kotlin, Kotest has coroutine support out of the box. Test cases can run inside a coroutineTestScope, turned on either in the config function of a single test case or globally for every test case in a spec. The test then runs on a TestDispatcher provided by the kotlinx.coroutines library, which lets us control virtual time within tests, skip delays, and so on.
Kotlin coroutines are such a broad subject that I won’t go into more detail about them in this post. Do watch our blog, though, for further articles about coroutines, which should be published there soon.
Data-Driven Testing
You may know parameterized tests from other testing frameworks (like JUnit 5’s @ParameterizedTest or Spock’s where keyword). Kotest’s data-driven tests are based on the same concept. The idea behind it is to:
- write a test case that takes parameters,
- prepare several sets of those parameters,
- run the test case with every parameter set, expecting it to pass each time.
Before using data-driven testing, you first have to add this dependency to your Gradle build file:
testImplementation("io.kotest:kotest-framework-datatest:$kotestVersion")
Here’s how you can build such test cases with Kotest:
context("numbers should add up to 10") {
withData(
Pair(5, 5),
Pair(3, 7),
Pair(1, 9)
) { (num1, num2) ->
num1 + num2 shouldBe 10
}
}
context("numbers should add up to given result") {
withData(
nameFn = { "${it.first } + ${it.second} = ${it.third}" }, // generate descriptive names for all cases
Triple(1, 2, 3),
Triple(10, 5, 15),
Triple(-5, 5, 0),
) { (num1, num2, result) ->
num1 + num2 shouldBe result
}
}
That wraps up our tour of the Kotest core module. Next, let’s look at the other great features the remaining two modules provide.
Assertions Library
The most important part of any test is its assertions. You’d probably be amazed if someone told you their project had 100% code coverage and every test always passed. That amazement would vanish, however, the moment they added that none of their tests contained assertions.
Luckily, Kotest ships with an extensive library of assertions for many data types. And thanks to Kotlin’s built-in syntactic sugar, Kotest assertions are also very expressive, handy, and readable.
To use the assertions library in your project, add the corresponding dependency to your build file:
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
Matchers
Matchers form the backbone of the Kotest assertions module. Think of a matcher as a function that checks whether a value matches what you expect. Kotest comes with many built-in matchers. Here are a few of them:
test("various matchers") {
(2 + 2) shouldBe 4
"text" shouldContain "x"
"non null text" shouldNotBe null
10 shouldBeGreaterThan 8
15L should beInstanceOf<Number>()
20 should beOfType<Int>()
mapOf("key" to "value") shouldContainValue "value"
listOf(1, 2, 3).shouldNotBeEmpty()
"{\"someProp\":\"value\"}" shouldContainJsonKey "someProp"
LocalDate.parse("2025-02-17") shouldBeAfter LocalDate.parse("2025-01-22")
}
You may have noticed that, among the other matchers in the example above, I used shouldContainJsonKey. It’s a special one, since it belongs to the JSON matchers. To use it or any other JSON matcher, you have to add one more dependency to your build file:
testImplementation("io.kotest:kotest-assertions-json:$kotestVersion")
Inspectors
Kotest also has a dedicated API for checking the elements of collections. Called Inspectors, it lets you match a collection’s contents in whatever way you need. Here’s an example of using inspectors:
test("Collection inspectors") {
val numbers = listOf(2, 4, 6, 8, 10)
numbers.forAll { it.shouldBeEven() }
numbers.forNone { it.shouldBeOdd() }
numbers.forSome { it shouldBeLessThan 5 }
numbers.forExactly(2) { it shouldBeGreaterThan 7 }
numbers.forAtMostOne { it shouldBeInRange 0..3 }
}
Custom matchers
If the standard library still doesn’t have a matcher you need, you can write your own. Keep in mind that Kotlin extension functions and infix functions are fully at your disposal for this!
All it takes is defining a function (or several) that serves as a matcher:
fun aGreetingTo(name: String) = Matcher<String> { value ->
MatcherResult(
value.matches(Regex("Hello $name!")),
{ "Message '$value' should be a greeting to $name!" },
{ "Message '$value' should not be a greeting to $name!" }
)
}
infix fun String.shouldBeAGreetingTo(name: String): String { // optional extension version of the matcher
this shouldBe aGreetingTo(name)
return this
}
infix fun String.shouldNotBeAGreetingTo(name: String): String { // optional negated extension version of the matcher
this shouldNotBe aGreetingTo(name)
return this
}
In tests, these matchers would then be used like this:
test("should message be a greeting to John") {
"Hello John!" shouldBe aGreetingTo("John") // custom matcher
"Hello Mary!" shouldNotBe aGreetingTo("John") // negated custom matcher
"Hello John!" shouldBeAGreetingTo("John") // extension custom matcher
"Goodbye John!" shouldNotBeAGreetingTo("John") // negated extension custom matcher
}
Composed matchers
Kotest also lets us combine different matchers (built-in as well as custom) into composed matchers. This way, we can merge our conditions into more complex ones and check either that every condition holds or that at least one of them does.
val containAllABC = Matcher.all(
contain("A"), contain("B"), contain("C")
)
val containAnyOfABC = Matcher.any(
contain("A"), contain("B"), contain("C")
)
test("composed matchers") {
"ABC" should containAllABC
"A" should containAnyOfABC
}
Soft assertions
One more small yet handy Kotest feature is support for soft assertions. By default, Kotest runs test cases with a fail-fast strategy, meaning test execution stops right at the first assertion that fails. This little feature, however, lets you run every assertion no matter whether some of them fail. The test case will, of course, still fail if any assertion fails; the only change is that all assertions get checked regardless.
test("soft assertions") {
val text = "Some text"
assertSoftly {
text shouldContain "no such string"
text shouldStartWith "S"
text shouldHaveLength 100
}
}
Non-deterministic testing
When we write unit tests, we’d ideally like the code under test to behave completely predictably and run instantly. Sadly, that isn’t always so. Sometimes we have to test asynchronous operations about which all we know is that they should complete at some point. How do we handle that? Kotest’s non-deterministic testing makes it easy.
test("should eventually store order") {
val order = Order("order-1", 99.99)
someAsynchronousDb.save(order)
eventually(10.seconds) { // verifies that something eventually happens
someAsynchronousDb.getById(order.id) shouldBe order
}
}
test("should keep data in cache according to TTL") {
val cacheTTL = 20.seconds
cache.put("entry-1", "some cached value")
continually(cacheTTL) { // verifies that some condition is true for the given period of time
cache["entry-1"] shouldBe "some cached value"
}
}
That covers everything I wanted to tell you about the Kotest Assertions Library. There’s still one more interesting thing to show you, though: Kotest’s final module – Property Testing.
Property Testing
The unit tests developers typically write rely on examples – they pass some sample input into the subject under test and expect particular results. This is known as example-based testing. It’s fine most of the time, but it has its weaknesses. For instance, our examples can easily miss certain edge cases. Defining more complex dummy test data by hand can also be tedious. But that’s not the only way to unit test code – there’s another approach, property-based testing, and Kotest supports it too.
In property-based testing, random test data, covering both edge cases and typical cases, is generated automatically, and the test is run many times with that generated data as input.
To use property testing in your project, add the following dependency to your Gradle build file:
testImplementation("io.kotest:kotest-property:$kotestVersion")
Property test functions
To illustrate how property tests are written in Kotest, here are a few property tests for the Fibonacci function:
class MyPropertyTestSpec: StringSpec({
"test fibonacci for n > 1 using forAll and arbitrary generator" { // 1
forAll(Arb.int(2..10)) { n ->
fibonacci(n) == fibonacci(n - 1) + fibonacci(n - 2)
}
}
"test fibonacci for n > 1 using checkAll" { // 2
checkAll(100, Arb.int(2..10)) { n ->
fibonacci(n) shouldBeEqual fibonacci(n - 1) + fibonacci(n - 2)
}
}
"test fibonacci for n > 1 using forAll and exhaustive generator" { // 3
forAll(Exhaustive.ints(2..10)) { n ->
fibonacci(n) == fibonacci(n - 1) + fibonacci(n - 2)
}
}
"test fibonacci for n < 0" { // 4
checkAll(Arb.int(max = -1)) { n ->
shouldThrow<IllegalArgumentException> { fibonacci(n) }
}
}
})
Four separate test cases are defined here, each showing a different side of Kotest. Let’s go through them one at a time:
- This is a basic property-based test case. The key element is the
forAllfunction, which runs its body many times (1000 times by default).Arb.int(2..10)is a generator that tells Kotest which values to feed into the test. Here, n will always be a random number from 2 to 10. Without a generator specified, Kotest would by default generate numbers fromInt.MIN_VALUEtoInt.MAX_VALUE. Another thing worth knowing aboutforAllis that it takes a lambda of type(a, …, n) -> Boolean, and for the test to pass, every call to the lambda must return true. - This test case closely resembles the previous one, with two main differences. First, we define our property-based test with the
checkAllfunction rather thanforAll.CheckAlltakes a lambda of type(a, …, n) -> Unit, so we can check our conditions with assertions – there’s no need to return a boolean like inforAll. Second, we set the number of iterations for the test explicitly, here 100. The body also differs slightly, of course, since we now check the function’s result with assertions instead of returning boolean values. - Looking at the two previous test cases, you may wonder: “Why run 1000 or even 100 iterations with random numbers just to test the deterministic Fibonacci function for values from 2 to 10?”. And you’d have a point – there’s a better option for this specific case, shown in test case number 3. Note that instead of an Arbitrary Generator for the n parameter, we use
Exhaustive.ints(2..10)here. As a result, Kotest generates every value from the given range and runs the test case exactly once per value. So rather than 1000 or 100 runs, we get 9 iterations that cover every value in the 2-10 range. - The fourth test case doesn’t introduce many new Kotest features compared with the earlier ones. Mainly, it shows another variant of the Arbitrary Generator for
Ints(a half-open set of Int values, fromInt.MIN_VALUEto -1). It also demonstrates that exceptions can be tested in a property-based test case.
Generator operations
The previous section introduced a few generators. You now know that either Arb or Exhaustive generators can produce data for our property-based tests. Before long (spoiler alert!), you’ll also find out about Custom Generators.
In this section, though, you’ll see that even the built-in generators come with handy operations that let us tailor them to our needs – from just taking the next item from a generator to sophisticated filtering and mapping of the value streams generators produce. Here are a few examples:
val someRandomString: String = Arb.string(1..10).next()
val oddNumbers: Arb<Int> = Arb.int().filter { it % 2 == 1 }
val prefixedStrings: Arb<String> = Arb.string(1..5).map { "PREFIX-$it" }
val suffixedStrings: Arb<String> = Arb.string(1..5).map { "$it-SUFFIX" }
val prefixedAndSuffixed: Arb<String> = prefixedStrings.merge(suffixedStrings)
The type declarations aren’t needed here. I added them just to show that most generator operations return generators as well, so we can use them in property tests as usual or transform and convert them further. The next operation stands out, since, as you can see, it retrieves an actual value from a generator.
Assumptions
At times, not every combination of input parameters makes sense for a test case. That’s where assumptions come in. They’re the right tool when we want to skip certain iterations of a test case depending on its parameters. Assumptions can be expressed as a conditional expression or even with assertions. Here are a few examples:
"test with assumptions conditional" {
checkAll<String, String> { a, b ->
withAssumptions(a != b) {
// test here
}
}
}
"test assume conditional" {
checkAll<String, String> { a, b ->
assume(a != b)
// test here
}
}
"test with assumptions assertions" {
checkAll<String, String> { a, b ->
withAssumptions({
a shouldNotBe b
}) {
// test here
}
}
}
"test assume assertions" {
checkAll<String, String> { a, b ->
assume {
a shouldNotBe b
}
// test here
}
}
Custom generators
As I hinted earlier, our property-based tests aren’t restricted to predefined generators. Kotest lets us write our own custom generators. In my view, this is especially handy when we want to generate instances of our own classes.
Both arbitrary and exhaustive generators can be implemented. The code snippet below shows how:
class Address(val city: String, val street: String, val number: Int, val zipCode: String)
val citiesGenerator = listOf("New York", "London", "Paris", "Berlin", "Hamburg").exhaustive()
val addressGenerator = arbitrary {
Address(
city = citiesGenerator.toArb().bind(), // cannot bind to exhaustive generator directly
street = Arb.string(5..20).bind(),
number = Arb.positiveInt(100).bind(),
zipCode = Arb.stringPattern("\\d{2}-\\d{3}").bind() // can also generate strings based on regex
)
}
Now we can generate Address instances just like we generate Ints or Strings and use them in property-based test cases. Nothing prevents us from using data generated like this in ordinary test cases either. Whenever we’d rather not define test data by hand, we can simply generate it.
That’s it for Kotest’s Property Testing module. I hope you found this information helpful and interesting.
Best Practices
Below are a few best practices worth remembering when working with Kotest:
- Give your tests and test functions descriptive names: Clear, meaningful names make it easier to see what each test checks, which is essential for maintaining and debugging your test suite.
- Group related tests with the
describefunction: Putting related tests together keeps your test code organized and easier to read. - Label and filter your tests with tags: Tags let you classify tests and run them selectively, which is particularly helpful in large projects.
- Write more effective tests with property-based testing and data-driven testing: These techniques help make sure your tests cover a broad range of inputs and scenarios, making your test suite more robust.
Combining with other technologies
As a ‘bonus’, here are a few ideas on using Kotest with popular JVM backend technologies.
Spring Boot
Let’s begin with what is unquestionably one of the most popular JVM web frameworks: Spring Boot. Kotest provides a dedicated, official Spring extension. If you have a Spring Boot Kotlin project, adding Kotest to it boils down to including these dependencies in your build file (Gradle in my case, though Maven works too):
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest.extensions:kotest-extensions-spring:$kotestSpringExtensionVersion")
Once that’s done, you can write tests that combine Spring Boot Test with Kotest:
@ContextConfiguration(classes = [MyConfiguration::class]) // configuration classes to use in tests
@ActiveProfiles("test") // active Spring profiles
class SpringBootKotestSampleSpec(
orderService: OrderService // injected dependency
) : FunSpec() {
override fun extensions() = listOf(SpringExtension) // adding Spring Extension to the test suite
init {
test("should find created order") {
println("Test context is ${testContextManager().testContext}") // testContextManager is available thanks to SpringExtension
// given
val orderId = orderService.placeOrder() // using injected service
// when
val order = orderService.findOrderById(orderId)
// then
order.orderId shouldBe orderId
}
}
}
Ktor
Another option is the web framework called Ktor. It’s a lightweight yet complete framework written in Kotlin, with support for many plugins and extensions for a variety of popular tools, such as different DBs, message brokers, and more. It also works with Kotest, thanks to the official Kotest extension for Ktor.
To use the Kotest extension in your Ktor project, just add these dependencies to your Gradle (or Maven) build file:
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest.extensions:kotest-assertions-ktor:$kotestKtorVersion")
After that, you can use Kotest’s dedicated assertions for Ktor HTTP responses:
test("test greeting endpoint") {
testApplication {
application {
module()
}
val response = client.get("/greetings/John")
// assertions below are provided by Ktor Extension
response.shouldHaveStatus(HttpStatusCode.OK)
response.shouldNotHaveContentEncoding("gzip")
response.shouldHaveHeader("Content-Type", "application/json; charset=UTF-8")
}
}
Kotest in Java project
So far, I’ve shown different ways of bringing Kotest into Kotlin projects built with various frameworks. But what if your project is in Java and, for whatever reason, you can’t (or would rather not) move fully to Kotlin? Even then, Kotest can still be useful, and I strongly encourage you to try it. Kotlin and Java both run on the JVM and can work together. So there’s nothing preventing you from writing production code in Java while using Kotlin (and Kotest) for unit tests. In my experience, this is a great and safe way to learn a new language and really put it to use in an actual project. I know people often do the same with Spock, a Groovy testing framework, pairing it with Java. So why not try Kotest in a similar way?
Alright, let’s say you’re convinced and you’ve got a Java project with a Gradle build file written in Groovy syntax. How do you start unit testing with Kotest there? All it takes is a small change to your build.gradle file:
plugins {
id 'java' // this is your Java plugin, that you already have
... // possibly some other Gradle plugins go here
id 'org.jetbrains.kotlin.jvm' version '2.1.10' // You need to add a Kotlin plugin for Gradle
}
dependencies {
...
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion") // core dependency for Kotest
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion") // other optional dependencies for Kotest, like Kotest Assertions
...
}
test {
useJUnitPlatform() // Kotest works on top of JUnit platform, so this stays unchanged
}
With Maven projects, it gets a little more complicated, but it’s still manageable:
<properties>
...
<kotlin.version>2.1.10</kotlin.version> <!-- You can add Kotlin version as property -->
<kotest.version>5.9.1</kotest.version> <!-- And Kotest version -->
</properties>
<build>
<plugins>
<plugin>
<!-- This is Kotlin Maven plugin that you need to include -->
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<!--
As we only want to use Kotlin in tests,
then just test-compile goal needs to be specified
-->
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--
As we changed the compilation process by adding Kotlin compiler,
we also need to do some changes to a default Maven compiler
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<executions>
<!-- Disable default compile tasks -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<!-- Define java-compile task which will only compile production code -->
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Here we add Kotest dependencies -->
<dependency>
<groupId>io.kotest</groupId>
<artifactId>kotest-runner-junit5</artifactId>
<version>${kotest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.kotest</groupId>
<artifactId>kotest-assertions-core</artifactId>
<version>${kotest.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
That’s it! You can now write ordinary Kotest test suites in the /src/test/kotlin directory of your Java project.
Wrap up
What a long ride this has been! My aim was to guide you through the many features of Kotest – a testing framework built in and for Kotlin. We explored the core features of the Test Framework module. We got to know a variety of handy matchers from the Assertions Library module. We became acquainted with the property-based testing approach provided by the Property Testing module. Lastly, we attempted (successfully!) to combine Kotest with a few other JVM frameworks and languages.
It really was a long ride, but it doesn’t have to stop here. For you, it may be only the beginning of a truly exciting adventure with Kotest in your projects and with exploring it further on your own! I hope you have fun with it!