You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In a Ktor server the single injected with a declareMock method in testApplication in a KoinTest/Kotest test doesn't override the service in main package.
Noticed that this issue is arising if there's a somewhat complicated routing setup (see reproduction repo for more details):
fun Application.configureRouting() {
testRouting()
}
...
fun Application.testRouting() {
routing {
val serviceA by inject<ServiceA>()
val serviceB by inject<ServiceB>()
test(serviceA, serviceB)
}
}
@Serializable
data classResponse(vala:String, valb:String)
fun Route.test(serviceA:ServiceA, serviceB:ServiceB) {
get("/test") {
call.respond(status =HttpStatusCode.OK, Response(serviceA.identify(), serviceB.identify()))
}
}
Expected behavior
I expected the declareMock method to inject the object created by Mockk in to Koin to be used in test instead of the service declared in the main application.
Koin module and version: koin-ktor:4.0.0 koin-test:4.0.0 Ktor:2.3.12 kotest-runner-junit5:5.9.1 kotest-extensions-koin:1.3.0
Describe the bug
In a Ktor server the
single
injected with adeclareMock
method intestApplication
in a KoinTest/Kotest test doesn't override the service in main package.Noticed that this issue is arising if there's a somewhat complicated routing setup (see reproduction repo for more details):
To Reproduce
Here's a repo with a sample project that reproduces this issue: https://github.com/mityakoval/KoinKotestSample
Just run
ApplicationTest
suite thereExpected behavior
I expected the
declareMock
method to inject the object created by Mockk in to Koin to be used in test instead of the service declared in the main application.Koin module and version:
koin-ktor:4.0.0
koin-test:4.0.0
Ktor:2.3.12
kotest-runner-junit5:5.9.1
kotest-extensions-koin:1.3.0
Snippet or Sample project to help reproduce
Sample project to reproduce: https://github.com/mityakoval/KoinKotestSample
The text was updated successfully, but these errors were encountered: