Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Does not work in Tests #59

Open
Vaibhav2002 opened this issue Oct 9, 2024 · 2 comments
Open

Bug: Does not work in Tests #59

Vaibhav2002 opened this issue Oct 9, 2024 · 2 comments
Assignees

Comments

@Vaibhav2002
Copy link

If i am creating Connectivity in tests, it fails to instantiate with this error

Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'dev.jordond.connectivity.Connectivity']'
	at app//org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:57)
	at app//org.koin.core.instance.SingleInstanceFactory.create(SingleInstanceFactory.kt:46)
	at app//org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:55)
	at app//org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:53)
	at app//org.koin.mp.KoinPlatformTools.synchronized(KoinPlatformTools.kt:36)
	at app//org.koin.core.instance.SingleInstanceFactory.get(SingleInstanceFactory.kt:53)
	at app//org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:109)
	at app//org.koin.core.scope.Scope.resolveValue(Scope.kt:247)
	at app//org.koin.core.scope.Scope.resolveInstance(Scope.kt:233)
	at app//org.koin.core.scope.Scope.get(Scope.kt:212)
	at app//com.medial.app.core.di.CoreModuleKt$_get_coreModule_$lambda$3$$inlined$singleOf$default$1.invoke(SingleOf.kt:227)
	at app//com.medial.app.core.di.CoreModuleKt$_get_coreModule_$lambda$3$$inlined$singleOf$default$1.invoke(SingleOf.kt:52)
	at app//org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:50)
	... 161 more
Caused by: java.lang.IllegalStateException: ContextProvider has not been initialized
	at dev.jordond.connectivity.tools.ContextProvider$Companion.getInstance(ContextProvider.kt:39)
	at dev.jordond.connectivity.AndroidConnectivityKt.Connectivity(AndroidConnectivity.kt:21)
	at dev.jordond.connectivity.AndroidConnectivityKt.AndroidConnectivity(AndroidConnectivity.kt:38)
	at dev.jordond.connectivity.MobileConnectivity_androidKt.Connectivity(MobileConnectivity.android.kt:17)
	at dev.jordond.connectivity.MobileConnectivity_androidKt.Connectivity$default(MobileConnectivity.android.kt:14)
	at com.medial.app.core.di.CoreModuleKt._get_coreModule_$lambda$3$lambda$1(CoreModule.kt:23)
	at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:50)
	... 173 more

Please provide a test version of this, so I can use in unit tests

@jhabaa
Copy link

jhabaa commented Dec 16, 2024

Hi, any solution ?

@jordond
Copy link
Owner

jordond commented Dec 31, 2024

Connectivity is exposed as an interface. So you can provide a fake implementation when running your tests.

One isn't currently included, and I can certainly add one. But it is pretty trivial to implement a basic fake for tests.

@jordond jordond self-assigned this Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants