There is a a registered primary stage call here an...
# tornadofx
a
There is a a registered primary stage call here and the only component here is a form. I suppose this makes sense, but it makes me curious, does this mean that when you call
FxToolkit.registerPrimaryStage( )
, do we do this to basically have a listener for the existence of components on the stage? I suppose using the
FxToolkit
is the JavaFX way of testing - does this mean that when you initialize TornadoFX `View`/`Fragment`, it is implied that there is a stage?
s
Whenever you want to create an instance of a JavaFX component, the JavaFX Toolkit must be initialised for it to render the components. Usually it is done when calling Application.launch(args) but when testing you may not want to create an "Application" just to test a
Form
so in that case you use
FxToolkit.registerPrimaryStage()
, which also returns the primary stage in case it is needed, but in the
FormTest
it is not.
a
So does this mean there are no special rules for a fragment to exist in testing?
So this comes down to testing a component versus the application. Testing a component in TornadoFX itself makes sense, but I don't know if it makes sense to test components over the application itself when creating TornadoFX apps, right?
s
I would say there are no special rules for fragments given that they are just a wrapper (over-simplification) for the
root
layout.
a
Interesting! In Android, fragments are required to exist on an activity, so I had to ask if it was a similar deal here. That's good to know!
s
About component testing, I wouldn't know what to say I've not made that many tests with JavaFX nor TornadoFX