Skip to main content

TestFX

Appel du stage

Appel de la fenêtre principale de l'application et fait un simple test.

@ExtendWith(ApplicationExtension.class)
class TableAppLauncherTest {


private static TableAppLauncher app;
@BeforeAll
static void setup() throws Exception {
app = new TableAppLauncher();
System.out.println("BeforeAll");
}



/**
* Méthode d'initialisation appelée avant chaque test
*
* @param stage La fenêtre (stage) injectée
*/
@Start
private void start(Stage stage) throws Exception {
//TableAppLauncher app = new TableAppLauncher();
app.start(stage);
System.out.println("Start");
}

@Test
void mmytest(FxRobot robot) throws InterruptedException {
TableView<Person> tableView = robot.lookup("#table").query();
assertThat(tableView, TableViewMatchers.hasTableCell("Laura"));
assertThat(tableView, TableViewMatchers.hasTableCell("George"));

TableRow<Person> n = robot.lookup(".table-row-cell").nth(1).query();
robot.clickOn(n);
sleep(10000);
}

Liens

https://github.com/TestFX/TestFX

Api doc

TableView Matcher

Idée utilisée pour trouver une cellule dans une Table

Exemple de test

)