Open
Description
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- I am running the latest versionI checked the documentation and found no answerI checked to make sure that this issue has not already been filed
Current Behavior
I'm working on a kotlin multiplatform project, when I try to write some unit test by using MockK, I got the Unresolved reference: xxx
error when I run the ./gradlew :common:build
, don't actually know this case relates to this issue(#58 ) or not.
...
> Task :common:linkTestDebugExecutableIos FAILED
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (3, 8): Unresolved reference: io
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (4, 8): Unresolved reference: io
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (5, 8): Unresolved reference: io
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (11, 4): Unresolved reference: MockK
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (18, 5): Unresolved reference: MockKAnnotations
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (26, 5): Unresolved reference: verify
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (40, 5): Unresolved reference: verify
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (52, 5): Unresolved reference: verify
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (59, 5): Unresolved reference: verify
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (66, 5): Unresolved reference: verify
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (73, 5): Unresolved reference: verify
e: xxx/accounting-multiplatform/android/common/src/commonTest/kotlin/com/littlegnal/accountingmultiplatform/data/SqlDelightManagerTest.kt: (80, 5): Unresolved reference: verify
8 actionable tasks: 8 executed
19:05:52: Task execution finished 'build'.
Steps to Reproduce
You can clone the project https://github.com/littleGnAl/accounting-multiplatform/tree/littlegnal/common-test.
Then run the ./gradlew :common:build
to reproduce
Context
My gradle configuration is like below:
apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'com.squareup.sqldelight'
apply plugin: 'kotlinx-serialization'
sqldelight {
AccountingDB {
packageName = "com.littlegnal.accountingmultiplatform"
}
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation deps.kotlin.stdlib.stdlib
implementation deps.kotlin.serialiaztion.runtime.common
implementation deps.kotlin.coroutines.common
}
}
commonTest {
dependencies {
implementation deps.kotlin.coroutines.core
implementation deps.kotlin.coroutines.common
implementation deps.kotlin.coroutines.test
implementation deps.kotlin.test.common
implementation deps.kotlin.test.annotations
// implementation deps.mockk.common
// implementation deps.mockk.mockk
implementation "io.mockk:mockk-common:1.9.3"
implementation "io.mockk:mockk:1.9.3"
}
}
androidTest {
dependencies {
implementation deps.kotlin.test.test
implementation deps.kotlin.test.junit
}
}
androidMain {
dependencies {
implementation deps.kotlin.stdlib.stdlib
implementation deps.sqldelight.runtimejvm
implementation deps.kotlin.serialiaztion.runtime.runtime
implementation deps.kotlin.coroutines.android
}
}
iosMain {
dependencies {
implementation deps.kotlin.stdlib.stdlib
implementation deps.sqldelight.driver.ios
implementation deps.kotlin.serialiaztion.runtime.native
implementation deps.kotlin.coroutines.native
}
}
iosTest {
dependencies {
implementation "io.mockk:mockk-common:1.9.3"
implementation "io.mockk:mockk:1.9.3"
}
}
}
targets {
fromPreset(presets.jvm, 'android')
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
? presets.iosArm64 : presets.iosX64
fromPreset(iOSTarget, 'ios') {
binaries {
framework('common')
}
}
}
}
// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations {
compileClasspath
}
task packForXCode(type: Sync) {
final File frameworkDir = new File(buildDir, "xcode-frameworks")
final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
final def framework = kotlin.targets.ios.binaries.getFramework("common", mode)
inputs.property "mode", mode
dependsOn framework.linkTask
from { framework.outputFile.parentFile }
into frameworkDir
doLast {
new File(frameworkDir, 'gradlew').with {
text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
setExecutable(true)
}
}
}
task iosTest {
def device = project.findProperty("iosDevice")?.toString() ?: "iPhone 8"
dependsOn 'linkTestDebugExecutableIos'
group = JavaBasePlugin.VERIFICATION_GROUP
description = "Runs tests for target 'ios' on an iOS simulator"
doLast {
def binary = kotlin.targets.ios.compilations.test.getBinary('EXECUTABLE', 'DEBUG')
exec {
commandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath
}
}
}
tasks.build.dependsOn packForXCode
- MockK version: 1.9.3
- OS: macOS Mojave 10.14.4
- Kotlin version: 1.3.31
- Type of test: unit test OR android instrumented test: Unit test
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
oleksiyp commentedon Jun 24, 2019
Thanks for the report
AdibaM commentedon Jul 31, 2019
Did you find a work around for this?
Bradleycorn commentedon Sep 18, 2019
same issue here ... any way to work around this?
desgraci commentedon Oct 1, 2019
Same issue Kotlin version: 1.3.50
[-]Unresolved reference when run the task linkTestDebugExecutableIos in kotlin multiplatform project[/-][+]Bug: Kotlin multiplatform project fails to build with mockk dependency[/+]heinhtetaung92 commentedon Mar 19, 2020
Hello. Same here. Any update on this?
danielocampo2 commentedon Jun 18, 2020
Had the same issue. For now I had to stop using mockk altogether for KMP as I don't know any workaround.
Is there any update?
Thanks!
xiaobailong24 commentedon Sep 4, 2020
Same issue with Kotlin multiplatform-1.4.0. Except new update to fix it.
jcfuerte commentedon Oct 10, 2020
Same Issue, someone has an update for this?
Thanks!
Ornolfr commentedon Oct 21, 2020
Any workaround available?
danielocampo2 commentedon Oct 21, 2020
I think basically mockk has no support for Kotlin Multiplatform so it is not possible to use this library with it.
jcfuerte commentedon Oct 21, 2020
probably soon it could be supported
21 remaining items