# Automating Exhaustive Branch Coverage for Sealed Types in Kotlin

DevFeed: [Automating Exhaustive Branch Coverage for Sealed Types in Kotlin](<https://devfeed.tech/articles/automating-exhaustive-branch-coverage-for-sealed-types-in-kotlin-20458.md>)

Original publisher: [Read original article](<https://eng.wealthfront.com/2025/11/20/sealed-tests/>)

Author: Sean Amos

Published: 2025-11-20T16:33:33Z

Content type: tutorial

Language: en

Sources: [Wealthfront](<https://devfeed.tech/sources/wealthfront.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Unit testing](<https://devfeed.tech/topics/unit-testing.md>), [test-coverage](<https://devfeed.tech/topics/test-coverage.md>), [Code quality](<https://devfeed.tech/topics/code-quality.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [automation](<https://devfeed.tech/tags/automation.md>), [code](<https://devfeed.tech/tags/code.md>), [code-quality](<https://devfeed.tech/tags/code-quality.md>), [exhaustive](<https://devfeed.tech/tags/exhaustive.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [sealed](<https://devfeed.tech/tags/sealed.md>), [sealed-classes](<https://devfeed.tech/tags/sealed-classes.md>), [subtype](<https://devfeed.tech/tags/subtype.md>), [test-coverage](<https://devfeed.tech/tags/test-coverage.md>), [testing](<https://devfeed.tech/tags/testing.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>), [wealthfront-engineering](<https://devfeed.tech/tags/wealthfront-engineering.md>)

## AI overview

This article explains how to build an Exhaustive Test Runner for Kotlin sealed classes and interfaces. The approach ensures that functions accepting sealed parameters have at least one unit test for each subtype, including future subtypes added to the hierarchy.

## Source excerpt

We take code correctness and code quality seriously at Wealthfront. One of the most effective ways we ensure that our code is correct is through rigorous unit testing and strong typing. In Kotlin, sealed classes and sealed interfaces offer a powerful tool to model restricted class hierarchies. They provide strong guarantees about the types in... Read more