diff --git a/greeting/android/build.gradle b/greeting/android/build.gradle index 8f38257..cfe8992 100644 --- a/greeting/android/build.gradle +++ b/greeting/android/build.gradle @@ -12,4 +12,6 @@ dependencies { // Specify dependency on a common project for Kotlin multiplatform build. expectedBy project(':greeting:common') + + testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" } diff --git a/greeting/android/src/test/kotlin/CalculatorTestJavaHelper.kt b/greeting/android/src/test/kotlin/CalculatorTestJavaHelper.kt new file mode 100644 index 0000000..3ec214c --- /dev/null +++ b/greeting/android/src/test/kotlin/CalculatorTestJavaHelper.kt @@ -0,0 +1,8 @@ +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import kotlin.test.Ignore + +// special class for running test within IDE +@Ignore +@RunWith(JUnit4::class) +class CalculatorTestJavaHelper : CalculatorTest() diff --git a/greeting/common/build.gradle b/greeting/common/build.gradle index f3ed1c6..35c85d8 100644 --- a/greeting/common/build.gradle +++ b/greeting/common/build.gradle @@ -9,4 +9,7 @@ version = 1.0 dependencies { // Set up compilation dependency on common Kotlin stdlib implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version" + + testImplementation "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version" } diff --git a/greeting/common/src/main/kotlin/Calculator.kt b/greeting/common/src/main/kotlin/Calculator.kt new file mode 100644 index 0000000..f74530b --- /dev/null +++ b/greeting/common/src/main/kotlin/Calculator.kt @@ -0,0 +1,5 @@ +class Calculator { + companion object { + fun sum(a: Int, b: Int): Int = a + b + } +} \ No newline at end of file diff --git a/greeting/common/src/test/kotlin/CalculatorTest.kt b/greeting/common/src/test/kotlin/CalculatorTest.kt new file mode 100644 index 0000000..92584c9 --- /dev/null +++ b/greeting/common/src/test/kotlin/CalculatorTest.kt @@ -0,0 +1,10 @@ +import kotlin.test.Test +import kotlin.test.assertEquals + +open class CalculatorTest { + + @Test + fun testSum() { + assertEquals(3, Calculator.sum(1, 2)) + } +} diff --git a/greeting/ios/build.gradle b/greeting/ios/build.gradle index a90f29b..a1a6472 100644 --- a/greeting/ios/build.gradle +++ b/greeting/ios/build.gradle @@ -9,6 +9,24 @@ konanArtifacts { // The multiplatform support is disabled by default. enableMultiplatform true } + + library('NativeLib') { + enableMultiplatform true + } + + program('NativeTest') { + srcDir 'src/test/kotlin' + commonSourceSet 'test' + libraries { + artifact 'NativeLib' + } + extraOpts '-tr' + } +} + +task test(dependsOn: 'compileKonanNativeTestIos_x64', type: Exec) { + def textExecutable = tasks["compileKonanNativeTestIos_x64"].artifactPath + commandLine("xcrun", "simctl", "spawn", "iPhone 8", textExecutable) } dependencies {