Hello. I have a ktor route that calls a simple business function to process data. The Route is responsible for receiving data from the body and passing it to the business function, and for formatting the returned values.
Like so:
get("/some/uri") {
val data = call.receive<SomeType>()
val result = doBusinessStuffWith(data)
call.respond(result.doSomeFormatting()
}
And the business function is defined somewhere else:
fun doBusinessStuffWith(data: SomeType): SomeReturnType {
...
}
Is there a way to test the controller in isolation by mocking the business function
doBusinessStuffWith
?
In Javascript, you can mock any function call with
jest
. I assume, it is not that easy in kotlin, but is there a nice way?
Thank you for your ideas …