Just getting started with TestFX and I'm wondering how to refer to the top Node
(i.e. the Stage
).
Here I see it says
All TestFX tests should use verifyThat(Node, Matcher, Function) when writing tests, so that the developer can use DebugUtils to provide additional info as to why a test failed.
This is a useful pointer... so say I want to say verify that "the JavaFX dialog/window is at least 600 pixels wide and at most 400 pixels high"?
NB for what it's worth I'm using the org.junit approach because the examples on the TestFX github site seem to. Actually I'm a Groovy fan and would hope to switch to the Spock TestFX implementation before too long.
NB2 it occurs to me that one way to get the Stage
in testing code is to make the Stage
a field of the class under test:
class ClickApplication extends Application {
Stage allTheWorldsA
public void start(Stage stage) {
Parent sceneRoot = new ClickPaneGG()
Scene scene = new Scene(sceneRoot, 500, 1000)
stage.setScene(scene)
stage.show()
allTheWorldsA = stage
}
... but somehow this feels the wrong way to do things: if the Stage
is passed as a parameter of start
it feels like the designers didn't want you to make a class field of it.