Skip to content

Commit

Permalink
test(ludo): Only show default route when not in test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStegii committed May 6, 2024
1 parent 40119f9 commit 6d433dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ludo/src/main/java/de/uniks/ludo/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public void start(Stage primaryStage) {
setDefaultResourceBundle(component.bundle());

// Starting the application by showing the main view without any parameters
show("");
if (!LudoUtil.inControllerTest()) {
show("");
}

} catch (Exception e) {
// If an error occurs while starting the application, we want to log it and exit the application
Expand Down
10 changes: 10 additions & 0 deletions ludo/src/main/java/de/uniks/ludo/LudoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@

public class LudoUtil {

private static final String CONTROLLER_TEST = "controller.test.enabled";

public static boolean inControllerTest() {
return Boolean.parseBoolean(System.getProperty(CONTROLLER_TEST));
}

public static void enableControllerTest() {
System.setProperty(CONTROLLER_TEST, Boolean.toString(true));
}

/**
* Plays a media/sound.
*
Expand Down
1 change: 1 addition & 0 deletions ludo/src/test/java/de/uniks/ludo/ControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ControllerTest extends ApplicationTest {

@Override
public void start(Stage stage) throws Exception {
LudoUtil.enableControllerTest();
super.start(stage);
this.stage = stage;
stage.requestFocus();
Expand Down

0 comments on commit 6d433dd

Please sign in to comment.