Sebastian Schuberth
07/20/2026, 6:42 AMval MyFirstTestSuite by testSuite {} my reflex is to remove this unused variable 😬Oliver.O
07/20/2026, 9:12 AMSebastian Schuberth
07/20/2026, 10:00 AMEugen Martynov
07/20/2026, 10:01 AMSebastian Schuberth
07/20/2026, 10:03 AMOliver.O
07/20/2026, 12:12 PMclass SimpleTestSuite :
TestSuite(
{
test("string length") {
assertEquals(8, "Test me!".length)
}
}
)
◦ Class using an init block:
class SimpleTestSuite : TestSuite {
init {
test("string length") {
assertEquals(8, "Test me!".length)
}
}
}
◦ Property:
val SimpleTestSuite by testSuite {
test("string length") {
assertEquals(8, "Test me!".length)
}
}
• The property delegate makes defining top-level test suites consistent with lower-level test suites. The syntax is almost identical, the main difference being that the suite name is auto-generated by default.
TL;DR: Conciseness, consistency, comprehensibility.Sebastian Schuberth
07/20/2026, 12:28 PMinit-block:
class CryptoHelperTest : FunSpec({
test("encryptSessionToken()") {
// ...
}
})
which arguably is not less readable than your last example. But I get your point, and in the end it boils down to a matter of taste.Oliver.O
07/20/2026, 1:02 PMSebastian Schuberth
07/20/2026, 1:03 PMOliver.O
07/20/2026, 1:03 PMOliver.O
07/20/2026, 5:35 PMtestSuite("weather service tests") {
// ...
}
and this pattern for a top-level test suite:
val WeatherServiceTests by testSuite {
// ...
}
And you know, it's the same thing, just a function invocation. Which means that instead of using the above functions, you could always provide your own custom ones.
If this were the world you were raised in, would you ever consider introducing classes instead?Sebastian Schuberth
07/20/2026, 5:53 PMval SimpleTestSuite by testSuite { vs. class SimpleTestSuite : FunSpec({, it's about the same length, where the one has more words, and the other more special chars. But if you also consider semantics, and you know that val ... by is actually instantiating something (on use) whereas class just defines a test class, the former could still feel a bit odd. But we're getting very theoretical now 😉Oliver.O
07/20/2026, 5:58 PMthatActually, using your terminology, it defines just the property. Like the class. Invoking the property's getter has the same effect as instantiating the class.is actually instantiating something (on use)val ... by
Sebastian Schuberth
07/20/2026, 6:41 PM