@@ -10,6 +10,7 @@ android {
10
10
targetSdkVersion 29
11
11
versionCode 1
12
12
versionName " 1.0"
13
+ testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
13
14
}
14
15
buildTypes {
15
16
release {
@@ -37,6 +38,7 @@ kotlin {
37
38
embedBitcode(" disable" )
38
39
linkerOpts(" -F$projectDir /../Carthage/Build/iOS" )
39
40
}
41
+ getTest(" DEBUG" ). linkerOpts(" -F$projectDir /../Carthage/Build/iOS" , " -framework" , " GCDWebServers" )
40
42
}
41
43
42
44
compilations. main. cinterops {
@@ -60,29 +62,68 @@ kotlin {
60
62
}
61
63
}
62
64
63
- // posixMain {
64
- // kotlin.srcDir("src/posix/kotlin")
65
- // dependencies {
66
- // implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-native', version: "1.3.4"
67
- // }
68
- // }
65
+ commonTest {
66
+ dependencies {
67
+ implementation ' org.jetbrains.kotlin:kotlin-test-common'
68
+ implementation ' org.jetbrains.kotlin:kotlin-test-annotations-common'
69
+ implementation ' io.ktor:ktor-client-core:1.3.2'
70
+ implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5-native-mt'
71
+ }
72
+ }
69
73
70
74
androidMain {
71
- dependencies {
72
- implementation ' org.jetbrains.kotlin:kotlin-stdlib'
73
- implementation ' com.squareup.okhttp3:mockwebserver:4.4.0'
74
- api ' com.squareup.okio:okio:2.6.0' // needed because of actual typalias Data
75
- }
75
+ dependencies {
76
+ implementation ' org.jetbrains.kotlin:kotlin-stdlib'
77
+ implementation ' com.squareup.okhttp3:mockwebserver:4.4.0'
78
+ api ' com.squareup.okio:okio:2.6.0' // needed because of actual typalias Data
79
+ }
76
80
}
77
81
78
- iosMain {
79
- // kotlin.srcDirs('src/posix/kotlin')
80
- // dependsOn posixMain
82
+ androidTest {
83
+ dependencies {
84
+ implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.5-native-mt'
85
+ implementation ' androidx.test.ext:junit:1.1.1'
86
+ implementation ' org.robolectric:robolectric:4.3.1'
87
+ implementation ' org.jetbrains.kotlin:kotlin-test'
88
+ implementation ' org.jetbrains.kotlin:kotlin-test-junit'
89
+ implementation ' io.ktor:ktor-client-android:1.3.2'
90
+ }
91
+ }
92
+
93
+ iosTest {
94
+ dependencies {
95
+ implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.5-native-mt'
96
+ implementation ' io.ktor:ktor-client-ios:1.3.2'
97
+ }
81
98
}
82
99
83
- // macOsMain {
84
- // kotlin.srcDirs('src/iOSMain/kotlin')
85
- // // dependsOn posixMain
86
- // }
87
100
}
88
- }
101
+ }
102
+
103
+ def testOutputFile () {
104
+ return kotlin. targets[" iosX64" ]. binaries. getTest(' DEBUG' ). outputFile
105
+ }
106
+
107
+ task copyGCDWebServers (type : Copy ) {
108
+ def testDir = testOutputFile(). parentFile. absolutePath
109
+ def path = " $testDir /Frameworks/GCDWebServers.framework"
110
+
111
+ from " $projectDir /../Carthage/Build/iOS/GCDWebServers.framework"
112
+ into path
113
+ }
114
+
115
+ task iosTest {
116
+ dependsOn ' linkDebugTestIosX64'
117
+ group = JavaBasePlugin . VERIFICATION_GROUP
118
+ description = " Runs tests for target 'ios' on an iOS simulator"
119
+
120
+ doLast {
121
+ def binary = testOutputFile(). absolutePath
122
+ exec {
123
+ commandLine ' xcrun' , ' simctl' , ' spawn' , ' booted' , binary
124
+ }
125
+ }
126
+ }
127
+
128
+ iosTest. dependsOn copyGCDWebServers
129
+ copyGCDWebServers. mustRunAfter(linkDebugTestIosX64)
0 commit comments