How might I exclude a certain set of tests from ru...
# kotlin-native
k
How might I exclude a certain set of tests from running only on iOS? I see there’s an
XCTest
Gradle task, but it doesn’t provide functionality like the
Test
task. Eg.
Copy code
tasks.withType<Test> {
   exclude("**/acceptance/**")
}
j
common:
Copy code
expect fun isIos(): Boolean

// In your test:
if (isIos()) return
non-native:
Copy code
actual fun isIos(): Boolean = false
native:
Copy code
actual fun isIos(): Boolean = Platform.osFamily == OsFamily.IOS
k
Oh that’s gonna be a headache
Sigh
e
Copy code
tasks.withType<KotlinNativeTest>().configureEach {
    args += "--ktest_negative_gradle_filter=*acceptance*"
}
🤞 1
k
Nice, I think that works. Thanks!
r
alternatively,
expect annotation class IosIgnore
with
actual typealias IosIgnore = kotlin.test.Ignore
on iOS and no-op on other platforms
k
Oh that’s a good idea, too.
e
you could also define the tests in a non-iOS sourceset,
Copy code
// build.gradle.kts
kotlin {
    applyDefaultHierarchyTemplate {
        common {
            group("nonIos") {
                withJs()
                withJvm()
                withAndroidNative()
                withMacos()
                withLinux()
                withMingw()
                withAndroidTarget()
                withWasmJs()
                withWasmWasi()
(of course you could trim that down to the targets you actually use) and then tests in
src/nonIosTest/kotlin/**
simply won't exist on iOS