Skip to content

Commit c75fd40

Browse files
qwwdfsadelizarov
authored andcommitted
Initialize JavaFx once [tests]
1 parent bac6bde commit c75fd40

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

ui/kotlinx-coroutines-javafx/test/JavaFxTest.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,28 @@ import org.junit.Test
1111
import kotlin.test.*
1212

1313
class JavaFxTest : TestBase() {
14+
15+
companion object {
16+
val fxEnabled: Boolean = try {
17+
initPlatform()
18+
true
19+
} catch (e: Throwable) {
20+
println("Skipping JavaFxTest in headless environment")
21+
false
22+
}
23+
24+
}
25+
1426
@Before
1527
fun setup() {
1628
ignoreLostThreads("JavaFX Application Thread", "Thread-", "QuantumRenderer-")
1729
}
1830

1931
@Test
2032
fun testDelay() {
21-
try {
22-
initPlatform()
23-
} catch (e: UnsupportedOperationException) {
24-
println("Skipping JavaFxTest in headless environment")
25-
return // ignore test in headless environments
26-
}
33+
if (!fxEnabled) {
34+
return // ignore test in headless environments
35+
}
2736

2837
runBlocking {
2938
expect(1)
@@ -41,10 +50,7 @@ class JavaFxTest : TestBase() {
4150

4251
@Test
4352
fun testRunBlockingForbidden() {
44-
try {
45-
initPlatform()
46-
} catch (e: UnsupportedOperationException) {
47-
println("Skipping JavaFxTest in headless environment")
53+
if (!fxEnabled) {
4854
return // ignore test in headless environments
4955
}
5056

0 commit comments

Comments
 (0)