TestBalloon styling – have it your way

Routinely, a test framework comes with its preferred style and TestBalloon is no exception: It registers test suites and tests via testSuite() and test() invocations.

As a DSL-based Kotlin-first framework, TestBalloon is obviously very flexible, letting us structure tests in plain Kotlin with parameters, loops and whatever it takes. But how much freedom does its API support? How far can we go if we want to change its look and feel?

Let's try, starting with two popular JavaScript styles from Jest and Mocha. But we won't stop there and find out if we could suppport the Gherkin grammar (Scenario/Given/When/And/Then) made popular by Cucumber, a BDD test framework.

Can we convince TestBalloon, via its public API, to accept a totally different structure?

Robolectric meets TestBalloon

GenAI said it would be impossible:

This integration is not feasible with the current TestBalloon architecture without significant changes to the compiler plugin or framework core.

Yet here it is – no significant changes, just an integration built with the public TestBalloon API.

So what do we have?

Robolectric brings fast, reliable and configurable Android tests to the JVM. It lets us operate close to the real device without waiting for dexing, packaging, installing and emulator start-up.

TestBalloon adds easily parameterized tests, nested test suites, test fixtures, and a Robolectric environment that can be fully configured in plain Kotlin, using a DSL, avoiding the restrictions of annotations.

Lifting Kotlin testing: Comparing JUnit, Kotlin-test, Kotest, Prepared and TestBalloon

Published on June 17, 2025 by Ivan “CLOVIS” Canet

Ivan compares several aspects of current Kotlin test frameworks in great detail and concludes:

Quote

With the recent birth of TestBalloon, we can see that there is still a lot of innovating in the space of test frameworks. Even after JUnit's dominance in the JVM ecosystem, we can still make tests easier to write and maintain. Kotlin makes possible patterns that we couldn't dream of in the Java world.

Read the full article (external site).