Are there any examples of testing `isFrozen`?
# kotlin-native
y
Are there any examples of testing
isFrozen
?
j
what is the problem. I guess the
assertTrue(hoge.isFrozen)
may work?
y
I need some annotations like
@Test
are available in native module.
isFrozen
is available only in it.
For JVM,
org.junit.Test
are prepared so I can test jvm actual code.
j
You may use
kotlin.test
as the library for tests. For JVM you may need to include
kotlin.test-junit
or
kotlin.test-junit5
. The native part for
kotlin.test
is embedded into the K/N standard library
I have the following setup of my MPP project
Copy code
kotlin { 
   sourceSets {
        commonTest {
            dependencies {
                implementation kotlin('test-common')
                implementation kotlin('test-annotations-common')
            }
        }
   }
}
y
Yes, I could use it in common module.
in iosTest module,
Copy code
@Test
fun frozenTest() {
    assertTrue(hoge.isFrozen)
}
Can you run this test?
j
I’m on 1.3.20. It works
I replace
hoge
with
Any()
I have several imports:
Copy code
import kotlin.native.concurrent.isFrozen
import kotlin.test.Test
import kotlin.test.assertTrue
y
Really? Thanks. I’ll retry!
@jonnyzzz Sorry, I could but thanks.
auto import didn’t work for this case so I was mistaken.
I wrote those
import
manually, then I could 🙏
j
It looks like you project is not imported correctly into IntelliJ IDEA. You may open
Gradle
tool window (CMD-Tab -> find it on the left part) and click refresh button in the tool window
y
Thanks
But, auto import doesn’t work only for test module (I tried only iosTest)
I’m using AndroidStudio3.3
It works in iosMain