I am attempting to integrate the TestFX framework into my application. I have run into an issue that I can't run multiple tests on the same fxml view. The GuiTest doesn't appear to tear down correctly and it leaves the stage open, causing errors on the second test.
public Parent getRootNode() {
FXMLLoader loader = new FXMLLoader();
Parent node = null;
try {
node = loader.load(
this.getClass().getResource("SampleWorkSpace.fxml").openStream());
} catch (IOException e) {
// Some error handling }
return node;
}
When this runs it throws a timeout error: java.util.concurrent.TimeoutException: Timeout waiting for task. However, my test continues from there.
Then I have the following test:
@Test
public void performANameSearch() {
TableView tv = (TableView)find("#resultsTable");
click("#NameTextField").type("Some Random Name");
click("#searchButton");
waitUntil(tv, TableViews.containsCell("Some Random Name"));
Assertions.verifyThat(tv, TableViews.containsCell("Some Random Name"));
}
This test works just fine.
However when I add test two:
@Test
public void performAnIDSearch() {
TableView tv = (TableView)find("#resultsTable");
click("#idTextField").type("1234567");
click("#searchButton");
waitUntil(tv, TableViews.containsCell("1234567"));
Assertions.verifyThat(tv, TableViews.containsCell("1234567"));
}
The test launches a second stage, types the ID in the correct field, invokes the correct search. However the waitUntil() gets the first TableView in the scene graph, causing it to timeout.
I have attempted to close the active window at the end of the first test - but that always closed before the assertions, so it would hang.
I tried breaking them into a suite, but that had the same issues as noted above.
I am unsure what else to try - I really don't want to have a single test per view as that would get very large, very quick....
Aucun commentaire:
Enregistrer un commentaire