Marek Kubiczek
04/04/2023, 1:01 PMandroidTestImplementation "io.mockk:mockk-android:${mockkVersion}"
androidTestImplementation "io.mockk:mockk-agent:${mockkVersion}"
But neither mockk-android nor mock-agent does include dependencies for mockk-jvm that contains all the methods like every, coEvery, verify etc.
So how is it supposed to work?Adam S
04/04/2023, 1:18 PMmockk-android
should automatically bring in the core mockk
dependency, because it’s exposed using API https://github.com/mockk/mockk/blob/6587d9bc616111eb3423aa1b9ba4c27f1e3addbf/modules/mockk-android/build.gradle.kts#L21-L25Adam S
04/04/2023, 1:20 PMMarek Kubiczek
04/04/2023, 1:21 PMMarek Kubiczek
04/04/2023, 1:21 PMMarek Kubiczek
04/04/2023, 1:22 PMmockk
and not mockk-jvm
. But actually mock itself doesn’t have much insideAdam S
04/04/2023, 1:23 PMmockk
vs mockk-jvm
is a Kotlin Multiplatform ‘thing’, which is unusual in MockK’s case because everything is JVM. But that shouldn’t concern Gradle users, since Gradle is clever so the -jvm
suffix can be droppedAdam S
04/04/2023, 1:25 PMMockK
file, a couple of files above the one you’ve selectedMarek Kubiczek
04/04/2023, 1:26 PMMarek Kubiczek
04/04/2023, 1:26 PMAdam S
04/04/2023, 1:26 PMAdam S
04/04/2023, 1:27 PM-jvm
suffix really shouldn’t be necessary, unless you’re using some custom way of fetching dependencies.
I wrote about what -jvm
means and how it works under the hood if you want to take a look :) https://stackoverflow.com/q/73914158/4161471Marek Kubiczek
04/04/2023, 1:28 PMAdam S
04/04/2023, 1:28 PMAdam S
04/04/2023, 1:29 PM./gradlew check
on the command lineMarek Kubiczek
04/04/2023, 1:47 PMmockk
without the -jvm didn’t help. The functions still cannot be resolved. And running from command line suffers the same problemAdam S
04/04/2023, 1:47 PMAdam S
04/04/2023, 1:47 PMMarek Kubiczek
04/04/2023, 1:50 PMfile://...CricketRepositoryIntegrationTest.kt:44:35 Unresolved reference: mockk
e: file://...CricketRepositoryIntegrationTest.kt:45:9 Unresolved reference: coEvery
e: file://...CricketRepositoryIntegrationTest.kt:45:19 Unresolved reference: getPopularEvents
e: file://...CricketRepositoryIntegrationTest.kt:45:36 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
Marek Kubiczek
04/04/2023, 1:50 PMAdam S
04/04/2023, 1:50 PMsrc/test/kotlin
?Adam S
04/04/2023, 1:51 PMMarek Kubiczek
04/04/2023, 1:51 PMMarek Kubiczek
04/04/2023, 1:51 PMAdam S
04/04/2023, 1:52 PMtestApi "io.mockk:mockk-android:${mockkVersion}"
? I think that testApi
should be availableAdam S
04/04/2023, 1:53 PMMarek Kubiczek
04/04/2023, 1:53 PMAdam S
04/04/2023, 1:53 PMAdam S
04/04/2023, 1:54 PMMarek Kubiczek
04/04/2023, 1:54 PMAdam S
04/04/2023, 1:55 PMMarek Kubiczek
04/04/2023, 1:56 PMMarek Kubiczek
04/04/2023, 2:00 PMAdam S
04/04/2023, 2:01 PM-jvm
works for you, then it works 🤷♀️Adam S
04/04/2023, 2:01 PMe: file://...CricketRepositoryIntegrationTest.kt:45:19 Unresolved reference: getPopularEvents
that’s not a MockK function, so it might indicate some other dependency is missing?Marek Kubiczek
04/04/2023, 2:01 PMAdam S
04/04/2023, 2:03 PMAdam S
04/04/2023, 2:03 PMMarek Kubiczek
04/04/2023, 2:04 PMMarek Kubiczek
04/04/2023, 2:21 PMAdam S
04/04/2023, 2:22 PMMarek Kubiczek
04/04/2023, 2:23 PMAdam S
04/04/2023, 2:23 PMMarek Kubiczek
04/04/2023, 6:28 PMAdam S
04/04/2023, 6:43 PMMarek Kubiczek
04/04/2023, 6:47 PMMarek Kubiczek
04/04/2023, 6:49 PMMarek Kubiczek
04/04/2023, 6:51 PM