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

iOS simulator tests support #1

Merged
merged 4 commits into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions greeting/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
8 changes: 8 additions & 0 deletions greeting/android/src/test/kotlin/CalculatorTestJavaHelper.kt
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 3 additions & 0 deletions greeting/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
5 changes: 5 additions & 0 deletions greeting/common/src/main/kotlin/Calculator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Calculator {
companion object {
fun sum(a: Int, b: Int): Int = a + b
}
}
10 changes: 10 additions & 0 deletions greeting/common/src/test/kotlin/CalculatorTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import kotlin.test.Test
import kotlin.test.assertEquals

open class CalculatorTest {

@Test
fun testSum() {
assertEquals(3, Calculator.sum(1, 2))
}
}
18 changes: 18 additions & 0 deletions greeting/ios/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down