Kotlin Test-Driven Development

Kotlin has emerged as a popular language for implementing object-oriented solutions for multiple target platform. The importance of testing Kotlin code thoroughly is clear. This course takes a thorough look at how to achieve this by using the Kotest library. You will learn how to write good tests, how to do so in a test-driven manner, and how to make best use of the power and flexibility afforded by the Kotest API.

Duration

2 days

 

Prerequisites

  • Comfortable with Kotlin programming

What you'll learn

  • Creating tests using Kotest
  • Using assertions and Kotest matchers
  • Adopting a test-driven approach to development
  • Using stubs and mock objects
  • TDD techniques
  • Kotest techniques

Course details

Getting Started with Testing

  • Setting the scene
  • Writing tests using JUnit 5
  • Writing tests using Kotest
  • Understanding Kotest spec syntax

Unit Testing Essentials

  • Defining unit tests
  • Best practices
  • Testing for exceptions

Kotest Matchers

  • A closer look at standard Kotest matchers
  • Defining custom matchers

Organising Tests

  • Nested tests
  • Isolation modes
  • Lifecycle hooks
  • Additional techniques

Managing Test Execution

  • Ordering tests
  • Tagging tests
  • Test factories

Test-Driven Development

  • Effective test-driven development
  • Refactoring techniques
  • Types of tests
  • Data-driven tests
  • Property-based tests

Test Doubles

  • Making code testable
  • Overview of test doubles
  • Using stubs
  • Using mocks