lundi 20 juillet 2015

Testing JavaFX application with JUnit

I've got rather simple JavaFX application:

public class Main extends Application {

@Override
public void start(Stage primaryStage) throws Exception {
    final int[] i = {0};
    FlowPane root = new FlowPane();
    root.setPadding(new Insets(40, 40, 40, 40));
    Button btn1 = new Button("Button 1");
    Button btn2 = new Button("Button 2");
    Label lbl = new Label("Output");
    Label lbl1 = new Label("Counter here");

    btn1.setOnAction(event -> { lbl.setText("Button 1 is pressed");
    lbl1.setText(""+ i[0]++);});

    btn2.setOnAction(event -> { lbl.setText("Button 2 is pressed");
        lbl1.setText(""+ i[0]++);});

    root.getChildren().addAll(lbl, btn1, btn2, lbl1);
    root.setId("root");
    primaryStage.setScene(new Scene(root, 100, 150));
    primaryStage.show();
}

public static void main(String[] args) {
    launch(args);
}
}

How can I test it with JUnit framework? What aspects of the app should be tested? I just want to understand how JavaFX applications are usually subjected to test.

Aucun commentaire:

Enregistrer un commentaire