Skip to content

wakingrufus/tornadofx-test

Repository files navigation

tornadofx-test

Kotlin extensions for TornadoFX and TestFX

Testing a View or Fragment

You can test a View or Fragment in isolation. Suppose you have the following Fragment:

class TestFragment : Fragment() {
    companion object : KLogging()

    val string: String by param()

    override val root = vbox {
        label(string){
            id = "label"
        }
    }
}

JUnit

Use the tornadofx-test-junit library to test your Views and Fragments with JUnit4

class TestFragmentTest : TornadoFxTest() {

    @Test
    fun test() {
        showViewWithParams<TestFragment>(mapOf("string" to "string"))

        verifyThat("#label", hasText("string"))
    }
}

Use the tornadofx-test-junit5 library to test your Views and Fragments with JUnit5

@ExtendWith(ApplicationExtension::class)
class TestFragmentTest : TornadoFxTest() {

    @Test
    fun test() {
        showViewWithParams<TestFragment>(mapOf("string" to "string"))

        verifyThat("#label", hasText("string"))
    }
}

About

Kotlin extensions for TornadoFX and TestFX

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages