Skip to content
Snippets Groups Projects
Commit 05178b75 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Experimental support for headless JavaFX tests using Monocle

parent 3000c395
No related branches found
No related tags found
No related merge requests found
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 # 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 # 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: ...@@ -11,7 +12,7 @@ cache:
variables: variables:
MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=.m2/repository" 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: build-job:
stage: build stage: build
......
...@@ -9,6 +9,31 @@ ...@@ -9,6 +9,31 @@
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</parent> </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> <dependencies>
<dependency> <dependency>
<groupId>tdt4140-gr1800</groupId> <groupId>tdt4140-gr1800</groupId>
...@@ -49,10 +74,6 @@ ...@@ -49,10 +74,6 @@
</dependency> </dependency>
</dependencies> </dependencies>
<properties>
<skip-ui-tests>false</skip-ui-tests>
</properties>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
......
package tdt4140.gr1800.app.ui; package tdt4140.gr1800.app.ui;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.testfx.framework.junit.ApplicationTest; import org.testfx.framework.junit.ApplicationTest;
...@@ -13,6 +14,13 @@ import javafx.stage.Stage; ...@@ -13,6 +14,13 @@ import javafx.stage.Stage;
public class FxAppTest extends ApplicationTest { public class FxAppTest extends ApplicationTest {
@BeforeClass
public static void headless() {
if (Boolean.valueOf(System.getProperty("gitlab-ci", "false"))) {
GitlabCISupport.headless();
}
}
@Override @Override
public void start(Stage stage) throws Exception { public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FxApp.fxml")); Parent root = FXMLLoader.load(getClass().getResource("FxApp.fxml"));
......
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");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment