Skip to content

Commit c19bbaa

Browse files
committed
try/catch errors
1 parent 8c57b0a commit c19bbaa

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

ganttproject/src/test/java/biz/ganttproject/app/PropertySheetTest.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import javafx.scene.control.TextField
55
import kotlinx.coroutines.CoroutineScope
66
import kotlinx.coroutines.Dispatchers
77
import kotlinx.coroutines.SupervisorJob
8+
import kotlinx.coroutines.cancel
89
import kotlinx.coroutines.javafx.JavaFx
910
import kotlinx.coroutines.launch
1011
import kotlinx.coroutines.withContext
@@ -13,19 +14,24 @@ import org.junit.jupiter.api.Test
1314
class PropertySheetTest {
1415
private val coroutineScope = CoroutineScope(SupervisorJob())
1516

16-
fun `basic string property`() {
17+
@Test fun `basic string property`() {
1718
coroutineScope.launch {
18-
withContext(Dispatchers.JavaFx) {
19-
val propertyPaneBuilder = PropertyPaneBuilder(DummyLocalizer, PropertyPane())
20-
val textProperty = ObservableString("prop1", "Lorem Ipsum")
21-
val editor = propertyPaneBuilder.createStringOptionEditor(textProperty)
22-
(editor as? TextField)?.let {
23-
it.text = "Hello"
24-
assert(textProperty.value == "Hello")
19+
try {
20+
withContext(Dispatchers.JavaFx) {
21+
val propertyPaneBuilder = PropertyPaneBuilder(DummyLocalizer, PropertyPane())
22+
val textProperty = ObservableString("prop1", "Lorem Ipsum")
23+
val editor = propertyPaneBuilder.createStringOptionEditor(textProperty)
24+
(editor as? TextField)?.let {
25+
it.text = "Hello"
26+
assert(textProperty.value == "Hello")
2527

26-
textProperty.value = "Hello2"
27-
assert(it.text == "Hello2")
28+
textProperty.value = "Hello2"
29+
assert(it.text == "Hello2")
30+
}
2831
}
32+
} catch (ex: Exception) {
33+
ex.printStackTrace()
34+
this.cancel()
2935
}
3036
}
3137
}

0 commit comments

Comments
 (0)