What would be a suitable way to replace a JUnit 5 ...
# kotest
d
What would be a suitable way to replace a JUnit 5
ParameterizedTest
with a
CSVSource
? I have two rows each with 3 values, but with the parameterized test, I have type safety by way of the method signature, which is myTest(Int, Int, String), my workaround for this is currently:
Copy code
checkAll(Exhaustive.of(Triple(1, 1, "A"), Triple(2, 3, "B")) { }
But this does not seem very elegant as I still have to bind the triple values to the named variables I want
e
Copy code
data class MyRowData(a: Int, b: Int, c: String) // Maybe there's a better name for this based on your domain

context("Checking triplets") {
  withData(
    MyRowData(1, 1, "A"),
    MyRowData(2, 3, "B")
  ) { (a, b, c) ->
    a + b shouldBe c
  }
}
Something like this? Would need to add
kotest-framework-datatest
dependency to use it
d
Oh I don't mind adding datatest as a dependency, it's at least more elegant than what I have now, thanks
For anyone finding this thread with a similar issue: https://kotest.io/docs/framework/datatesting/data-driven-testing.html
Seems like Maven does not like this module, it adds the dependency alright, but in the actual test it does not find the
withData
extension function, I noticed the module is in a 'weird' format, since it has .knm files so maybe that has something to do with it
My project is a Spring Boot application
Ah found it, for anyone having the same issue, obviously you need the -jvm module, so
kotest-framework-datatest-jvm