Commit 05178b75 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Experimental support for headless JavaFX tests using Monocle

parent 3000c395
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
......
......@@ -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>
......
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"));
......
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");
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment