Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Unit Testing (Part 2)

Part 1 explored the basic principles of unit testing and introduced Kotest, a powerful testing framework for Kotlin software.

In this follow-up, you will learn about richer and more powerful assertions, with which you can check that floating-point values, strings and collections have the expected form, or that exceptions are thrown when expected.

You will also learn about how test fixtures allow you to set up a consistent environment for running tests.

You will apply what you’ve learned so far about Kotest in a scenario that introduces you to the concept of test-driven development, whereby tests are written before the code that needs to be tested.

Finally, you’ll learn how to isolate unit tests from external dependencies using test doubles.

At the end of all this, you should have a solid grounding in how to write automated tests for Kotlin software using Kotest. We will return to testing later in the module.