Simple play icon Course
Skills Expanded

Unit Testing with JUnit 5 and Kotlin 1

by Kevin Jones

Kotlin is rapidly growing on the JVM (Java Virtual Machine) and this course will show you how to use JUnit 5 to make sure this code is tested and testable.

What you'll learn

JUnit 5 is the de-facto standard testing framework on the JVM. It is used to test application code in many areas including enterprise, desktop, and mobile applications.

In this course, Unit Testing with JUnit 5 and Kotlin 1, you will learn how to set up JUnit to test Kotlin code, including some of the issues you will encounter that are unique to Kotlin.

First, you will see how to set up your environment to use JUnit 5 for Kotlin including setting up Gradle and Maven environments and using an IDE to run the tests.

Next, you will be introduced to Kluent, a Kotlin fluent assertions library. Then, you will see how to change assertions using this fluent syntax, as well as new, cleaner ways of writing assertions using the Kluent APIs.

Finally, you will explore ‘mocking’ using MockK, a mocking framework written in and for Kotlin.

When you are finished with this course, you will have the skills to test Kotlin code using JUnit and how to refactor code to make it testable.

About the author

A long time ago in a university far, far away Kevin fell in love with programming. Initially on the university's DEC20 computer doing BASIC and Pascal and a little bit of Fortran. His first job had him writing batch PL/1 on an IBM mainframe where he also discovered the arcane delights of JCL. He soon realized the multiuser systems were not for him after discovering the delights of dBase IV on IBM PCs. From here it was all downhill as he became addicted to C and the Windows API. Just missing out ... more

Ready to upskill? Get started