Starting with a Canary Test

Canary test

A canary test is a test that asserts that true is equal to true. That sounds silly, as it appears that such a test isn’t doing much, but starting with a canary test is a good way to verify that the project is set up properly with the necessary tools. If we run into any errors at this stage, it’s easier to ask for help, in a team setting, from just about anyone who knows the tools.

From the design diagram we saw in the previous lesson (The Code Under Test), the AirportTest is a good starting point. Let’s create a test suite, using KotlinTest, with just one test in it.

Practice Along by Starting with a Sample Project

The best way to gain a deeper understanding of writing tests is to practice. To make it easier for you, the source code repository contains an airportapp directory that has both the Gradle and Maven build files. On your system, change to the airportapp directory and create your files there, using the subdirectory names and files specified in the text in this chapter. Since we’ll be evolving code incrementally using tests, if you click on the links above the code listings in this chapter, you’ll see the partial code instead of the complete code.

Create a file named AirportTest.kt under the src/test/kotlin/com/agiledeveloper/airportstatus directory.

Get hands-on with 1200+ tech skills courses.