Hello all! I hope you’re doing great today! I am f...
# koin
t
Hello all! I hope you’re doing great today! I am fairly new to Koin and DI and am trying to understand the testing side. Running individual tests and classes have no issues. But when running all my test classes via Gradle task I’m fighting against KoinAlreadyStarted at GlobalContext errors on all my Test classes that implement a ViewModel from Koin. Has anyone experienced this before and can advise? Maybe even testing best practices could be helpful. I’ve tried KoinRules and @Before/After for setup and cleanup too and I do not get a different error or result.
k
koin version?
t
@Kibet Theophilus 3.5.3 is the version I’ve been using. I discovered after some tinkering that I may need to be abstracting my data differently to allow for testing. I just reworked my Home functionality into HomeScreen/ViewModel/Container/UiState and I believe I will have an easier time testing it as a result. Here’s my GitHub for the project: https://github.com/timkaragosian1/2025TrainingApp
a
Looks good 👍
t
@Alexandru Caraus I appreciate you taking a look! Do you mean I should be able to test it now with the abstracted way it is now? It’s a little different than my design for the SignInScreen and VM that allowed for instrument testing easily (and I still need to build unit tests there as well). My History classes are the old style I was trying to implement and could not get testing working at all for, but it lacks the same abstraction and organization. I know once I get a solid working example or two then everything else will click in probably, I’m just struggling some in getting over the barrier to entry.