From 20344931ce50df3b3b4601dca5c0cbec01b1e80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Moreira?= Date: Sat, 1 Nov 2025 21:19:13 -0300 Subject: [PATCH 1/2] Adding uncovered test cases to Verification - Related to gh-2300 --- .../kotlin/org/koin/test/Components.kt | 14 ++++ .../src/jvmTest/kotlin/VerifyModulesTest.kt | 79 +++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/projects/core/koin-test/src/commonTest/kotlin/org/koin/test/Components.kt b/projects/core/koin-test/src/commonTest/kotlin/org/koin/test/Components.kt index 22fd61b74..3e75f1077 100644 --- a/projects/core/koin-test/src/commonTest/kotlin/org/koin/test/Components.kt +++ b/projects/core/koin-test/src/commonTest/kotlin/org/koin/test/Components.kt @@ -27,6 +27,20 @@ class Simple { class MyComplexBool(val a : ComponentA, val b : Boolean) fun buildB(a: ComponentA) : MyComponentB = ComponentB(a) + + class ComponentProvider { + fun getComponent(): ComponentToBeProvided { + return ComponentToBeProvided() + } + + fun getComponentWithArg(a: ComponentA): ComponentToBeProvidedWithComponentA { + return ComponentToBeProvidedWithComponentA(a = a) + } + } + + class ComponentToBeProvided + + class ComponentToBeProvidedWithComponentA(val a: ComponentA) } object UpperCase : Qualifier { diff --git a/projects/core/koin-test/src/jvmTest/kotlin/VerifyModulesTest.kt b/projects/core/koin-test/src/jvmTest/kotlin/VerifyModulesTest.kt index ee0c13137..4639c4d32 100644 --- a/projects/core/koin-test/src/jvmTest/kotlin/VerifyModulesTest.kt +++ b/projects/core/koin-test/src/jvmTest/kotlin/VerifyModulesTest.kt @@ -8,6 +8,10 @@ import org.koin.dsl.module import org.koin.test.Simple import org.koin.test.verify.* +/** +* @author Arnauld Giuliani +* @author Otávio Moreira +* */ class VerifyModulesTest { @Test @@ -262,4 +266,79 @@ class VerifyModulesTest { e.printStackTrace() } } + + @Test + fun `verify instance provided by other definition`() { + val modules = module { + single { Simple.ComponentProvider() } + single { + get().getComponent() + } + } + + modules.verify() + } + + @Test + fun `verify instance provided by other definition - fail`() { + val modules = module { + single { + get().getComponent() + } + } + + try { + modules.verify() + fail() + } catch (e: Exception) { + e.printStackTrace() + } + } + + @Test + fun `verify instance provided by other definition passing arg`() { + val modules = module { + single { Simple.ComponentA() } + single { Simple.ComponentProvider() } + single { + get().getComponentWithArg(a = get()) + } + } + + modules.verify() + } + + @Test + fun `verify instance provided by other definition passing arg - fail without provider`() { + val modules = module { + single { Simple.ComponentA() } + single { + get().getComponentWithArg(a = get()) + } + } + + try { + modules.verify() + fail() + } catch (e: Exception) { + e.printStackTrace() + } + } + + @Test + fun `verify instance provided by other definition passing arg - fail without arg`() { + val modules = module { + single { Simple.ComponentProvider() } + single { + get().getComponentWithArg(a = get()) + } + } + + try { + modules.verify() + fail() + } catch (e: Exception) { + e.printStackTrace() + } + } } From 00608b6d6d6a06ceb4bed077ebf1f511ed056577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Moreira?= Date: Sat, 1 Nov 2025 21:24:44 -0300 Subject: [PATCH 2/2] Removes deprecation of CheckModules - Related to gh-2300 --- .../kotlin/org/koin/test/check/CheckModules.kt | 16 ---------------- .../org/koin/test/check/CheckModulesDSL.kt | 2 -- 2 files changed, 18 deletions(-) diff --git a/projects/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModules.kt b/projects/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModules.kt index b30d663df..202bec8b5 100644 --- a/projects/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModules.kt +++ b/projects/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModules.kt @@ -40,10 +40,6 @@ import org.koin.test.parameter.MockParameter /** * Check all definition's dependencies - start all modules and check if definitions can run */ -@Deprecated( - message = "Migrate to verify() API", - replaceWith = ReplaceWith("org.koin.test.verify.Verify") -) fun KoinApplication.checkModules(parameters: CheckParameters? = null) = koin.checkModules(parameters) /** @@ -53,10 +49,6 @@ fun KoinApplication.checkModules(parameters: CheckParameters? = null) = koin.che * @param parameters - parameter setup * @param appDeclaration - koin Application */ -@Deprecated( - message = "Migrate to verify() API", - replaceWith = ReplaceWith("org.koin.test.verify.Verify") -) fun checkModules(level: Level = Level.INFO, parameters: CheckParameters? = null, appDeclaration: KoinAppDeclaration) { startKoin(appDeclaration) .logger(KoinPlatformTools.defaultLogger(level)) @@ -70,10 +62,6 @@ fun checkModules(level: Level = Level.INFO, parameters: CheckParameters? = null, * @param appDeclaration - Koin app config if needed * @param parameters - Check parameters DSL */ -@Deprecated( - message = "Migrate to verify() API", - replaceWith = ReplaceWith("modules.verifyAll()", "org.koin.test.verify.verifyAll") -) fun checkKoinModules(modules: List, appDeclaration: KoinAppDeclaration = {}, parameters: CheckParameters? = null) { startKoin(appDeclaration) .modules(modules) @@ -110,10 +98,6 @@ fun checkKoinModules(vararg modules: Module, level: Level = Level.INFO, paramete /** * Check all definition's dependencies - start all modules and check if definitions can run */ -@Deprecated( - message = "Migrate to verify() API", - replaceWith = ReplaceWith("org.koin.test.verify.Verify") -) fun Koin.checkModules(parametersDefinition: CheckParameters? = null) { logger.info("[Check] checking modules ...") diff --git a/projects/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModulesDSL.kt b/projects/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModulesDSL.kt index f563f4df4..fe319647c 100644 --- a/projects/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModulesDSL.kt +++ b/projects/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModulesDSL.kt @@ -26,10 +26,8 @@ import kotlin.reflect.KClass //TODO TO BE DEPRECATED in 4.0 -@Deprecated("Migrate to verify() API") data class CheckedComponent(val qualifier: Qualifier? = null, val type: KClass<*>) -@Deprecated("Migrate to verify() API") class ParametersBinding(val koin: Koin) { val parametersCreators = mutableMapOf()