Davide Giuseppe Farella
02/22/2023, 3:50 PMMockAppExtension
(previously MockAppRule
) that sets up Koin with Ktor’s `MockEngine`s and in-memory SqlDelight database.
I have 3 test classes with 17 tests in total. If I run a single class, all of them pass with no problem, but if I run tests for the whole module, 2 out of 17 fail with io.ktor.serialization.JsonConvertException: Illegal input
on a network request
I wonder what could make the difference 🤔 I tried with different `IsolationMode`sobject MockEngines
and in some tests I use MockEngines.xyz.setHandler
, so on Kotest this same modified engine is persisted across all the tests, thus my successive api request receive an unexpected Json, as I don't set any constraints on that handler for simplicity of the codedave08
02/26/2023, 3:42 AMDavide Giuseppe Farella
02/26/2023, 8:18 AMTraktAuthEngine
, TmdbMovieEngine
,etc, that can be reused easily for Unit tests
• Merge multiple `MockEngine`s into a single one, to use for Integration tests
• Add dynamic handlers to override a single request
If you’re interested, here are my utils; still need some refactor, specially regarding MockEngine.plus
where there is some code duplicated from below, but it does its job
https://github.com/4face-studi0/CineScout/blob/main/cinescout/network/src/commonMain/kotlin/cinescout/network/testutil/ktorEngineUtils.ktdave08
02/26/2023, 9:50 AMDavide Giuseppe Farella
02/26/2023, 9:58 AM