diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c83acd34b8a6e8a15f513005f0b30b77021c421e..0c2a71585d2cad6ae23ea8b5b3f469baab805eb4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,5 @@ -image: kaiwinter/docker-java8-maven +image: krissrex/docker-java8-maven-testfxmonocle:1.0 +# image: kaiwinter/docker-java8-maven # image: maven:3.3.9-jdk-8 # most of this taken from https://stackoverflow.com/questions/37785154/how-to-enable-maven-artifact-caching-for-gitlab-ci-runner @@ -11,7 +12,7 @@ cache: variables: MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=.m2/repository" - MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -Dskip-ui-tests=true" + MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -Dgitlab-ci=true build-job: stage: build diff --git a/tdt4140-gr1800/app.ui/pom.xml b/tdt4140-gr1800/app.ui/pom.xml index 05117408d2c6600bf0fa6016eaef79f91d5e7cb3..579df81e55489bae63518b2d9f6055333cb5898c 100644 --- a/tdt4140-gr1800/app.ui/pom.xml +++ b/tdt4140-gr1800/app.ui/pom.xml @@ -9,6 +9,31 @@ <version>0.0.1-SNAPSHOT</version> </parent> + <profiles> + <profile> + <id>gitlab-ci</id> + <activation> + <property> + <name>gitlab-ci</name> + <value>true</value> + </property> + </activation> + <!-- + <properties> + <skip-ui-tests>true</skip-ui-tests> + </properties> + --> + <dependencies> + <dependency> + <groupId>org.testfx</groupId> + <artifactId>openjfx-monocle</artifactId> + <version>8u76-b04</version> <!-- jdk-9+181 for Java 9 --> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + </profiles> + <dependencies> <dependency> <groupId>tdt4140-gr1800</groupId> @@ -49,10 +74,6 @@ </dependency> </dependencies> - <properties> - <skip-ui-tests>false</skip-ui-tests> - </properties> - <build> <plugins> <plugin> diff --git a/tdt4140-gr1800/app.ui/src/test/java/tdt4140/gr1800/app/ui/FxAppTest.java b/tdt4140-gr1800/app.ui/src/test/java/tdt4140/gr1800/app/ui/FxAppTest.java index 254f7822034c0a421590a09009167476443a6447..5bded2b5f54d04a93d671277315385eaaaf1a542 100644 --- a/tdt4140-gr1800/app.ui/src/test/java/tdt4140/gr1800/app/ui/FxAppTest.java +++ b/tdt4140-gr1800/app.ui/src/test/java/tdt4140/gr1800/app/ui/FxAppTest.java @@ -1,6 +1,7 @@ package tdt4140.gr1800.app.ui; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; import org.testfx.framework.junit.ApplicationTest; @@ -13,6 +14,13 @@ import javafx.stage.Stage; public class FxAppTest extends ApplicationTest { + @BeforeClass + public static void headless() { + if (Boolean.valueOf(System.getProperty("gitlab-ci", "false"))) { + GitlabCISupport.headless(); + } + } + @Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("FxApp.fxml")); diff --git a/tdt4140-gr1800/app.ui/src/test/java/tdt4140/gr1800/app/ui/GitlabCISupport.java b/tdt4140-gr1800/app.ui/src/test/java/tdt4140/gr1800/app/ui/GitlabCISupport.java new file mode 100644 index 0000000000000000000000000000000000000000..2a1c9d73ae9e99feabcba4d320e1b8dd097e8125 --- /dev/null +++ b/tdt4140-gr1800/app.ui/src/test/java/tdt4140/gr1800/app/ui/GitlabCISupport.java @@ -0,0 +1,16 @@ +package tdt4140.gr1800.app.ui; + +public class GitlabCISupport { + + public static void headless() { + System.setProperty("prism.verbose", "true"); // optional + System.setProperty("java.awt.headless", "true"); + System.setProperty("testfx.robot", "glass"); + System.setProperty("testfx.headless", "true"); + System.setProperty("glass.platform", "Monocle"); + System.setProperty("monocle.platform", "Headless"); + System.setProperty("prism.order", "sw"); + System.setProperty("prism.text", "t2k"); + System.setProperty("testfx.setup.timeout", "2500"); + } +}