master
Oystein 2021-04-26 20:09:24 +02:00
commit 057c1e0074
2 changed files with 2 additions and 46 deletions

View File

@ -1,44 +0,0 @@
package app;
import javafx.scene.Node;
import javafx.stage.Stage;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.testfx.api.FxToolkit;
import org.testfx.framework.junit5.ApplicationTest;
import org.testfx.util.WaitForAsyncUtils;
import java.util.concurrent.TimeoutException;
public class FxTestTemplate extends ApplicationTest {
private Stage stage;
@BeforeEach
public void runAppToTests() throws Exception {
FxToolkit.registerPrimaryStage();
FxToolkit.setupApplication(Main::new);
FxToolkit.showStage();
WaitForAsyncUtils.waitForFxEvents(100);
}
@AfterEach
public void stopApp() throws TimeoutException {
FxToolkit.cleanupStages();
}
@Override
public void start(Stage primaryStage){
this.stage = primaryStage;
primaryStage.toFront();
}
public Stage getStage() {
return stage;
}
public <T extends Node> T find(final String query) {
/** TestFX provides many operations to retrieve elements from the loaded GUI. */
return lookup(query).query();
}
}

View File

@ -64,7 +64,7 @@ public class EditorControllerTest extends FxTestTemplate {
private String mockContent = """
class HelloWorld {
private String message = "Hello world";
private String message = \"Hello world\";
public String getMessage() {
return message;
@ -108,7 +108,7 @@ public class EditorControllerTest extends FxTestTemplate {
String brokenFilePath = "/doesNotExist.txt";
eventBus.post(new OpenFileEvent(Optional.ofNullable(Paths.get(brokenFilePath))));
verify(editor, never()).clear();
verify(editor).appendText("");
}
}