Writing Empirical Tests

Empirical tests are common in unit testing—you call a method and verify that it did what you expected. Such tests help us to verify that, as code evolves, the expectations are still met and the code continues to work as intended.

Empirical tests are useful for functions and methods that are deterministic and don’t have any dependencies that hold state. We’ll create a few empirical tests for the Airport class now.

First, let’s create some properties in the test suite using the yet-to-be-written Airport class. For this, within the AirportTest class, let’s define a few sample properties before the init() function:

 val​ iah = Airport(​ ...

Get Programming Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.