Kotlin Multiplatform parameterized tests with Burst
Article Summary
Cash App just open-sourced Burst 2.0, bringing parameterized testing to Kotlin Multiplatform. No more writing the same test multiple times for different inputs.
Jesse Wilson from Cash App announced Burst 2.0, a Gradle plugin that fills a major gap in Kotlin Multiplatform testing. While JUnit has had parameterized tests for years (via Burst 1.0, TestParameterInjector, and @ParameterizedTest), KMP projects have been missing this capability until now.
Key Takeaways
- Add @Burst annotation to test classes and parameters to constructors or functions
- Automatically tests all combinations across every KMP target platform
- Enums and booleans work without burstValues(), testing all possible values
- First argument in burstValues() becomes default for IDE testing
- Spiritual successor to Square's original Burst library, hence version 2.0
Burst 2.0 brings parameterized testing to Kotlin Multiplatform, letting you write one test and run it across multiple algorithms, inputs, and environments automatically.
About This Article
Kotlin Multiplatform developers couldn't do parameterized testing the way JUnit users could with their various libraries and extensions.
Cash App built Burst 2.0, a Gradle plugin that lets you add @Burst annotations to test classes. You define test cases with burstValues() on constructor or function parameters.
Now you can write one test and have it run automatically across every parameter combination on all your Kotlin Multiplatform target platforms. No need to duplicate anything.