Created
August 3, 2020 22:17
-
-
Save mathias21/1f254339590a074751b71f25a821e4d4 to your computer and use it in GitHub Desktop.
KtorEasy controller testing: instrumentation 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseControllerTest { | |
private val databaseProvider: DatabaseProviderContract = mockk() | |
init { | |
stopKoin() | |
} | |
open fun before() { | |
clearMocks(databaseProvider) | |
coEvery { databaseProvider.dbQuery(any<() -> Any>()) } coAnswers { | |
firstArg<() -> Any>().invoke() | |
} | |
} | |
fun startInjection(module: Module) { | |
startKoin { | |
modules( | |
module, | |
module { | |
single(override = true) { databaseProvider } | |
} | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment