nfa
08/10/2026, 11:58 AMimport de.nielsfalk.dataTables.Data
import io.kotest.core.spec.style.FreeSpec
class HelloSpockTest : FreeSpec({
"length of Spock's and his friends' names" - {
@Data("name" , "expectedLength") Spock {
"Spock" ǀ 5
"Kirk" ǀ 4
"Scotty" ǀ 6
}.each {
"${name}'s name has length $expectedLength" {
assert(name.length == expectedLength)
}
}
}
})
I’m a fan of the good old Spock Framework, especially its data tables & power asserts, and I’m trying to bring some of that expressiveness to Kotlin.
I’d really appreciate feedback from Kotest users:
• Do you like this style?
• Would you consider using something like this in your projects?
• Is there anything about it that feels awkward or surprising?Vampire
08/10/2026, 12:16 PMnfa
08/10/2026, 1:09 PMAlex Kuznetsov
08/10/2026, 2:34 PMAlex Kuznetsov
08/10/2026, 2:35 PMlistOf(
TestCase(name = "Kirk", expectedLength = 4)
(snip)Alex Kuznetsov
08/10/2026, 2:36 PMVampire
08/10/2026, 2:36 PMif I need a wider value, all formatting needs to changIt does not need to, it just improves readability, but is not a necessity. Also, you don't need to use data tables at all, they are overall just syntax sugar for multiple data providers with fixed values.
less type safetyNo, you have full type safety if you wish so, just declare the type as method parameter like for all data variables
Alex Kuznetsov
08/10/2026, 2:37 PMVampire
08/10/2026, 2:38 PMnfa
08/10/2026, 3:20 PMcan you share what power asserting features you are missing in Kotest?no I like the way the official kotlin compiler plugin does it ( copied from groovy wich was inspired by Spock ( first spock than general groovy assertion feature) ), I can use it in kotest. So I’m fine.