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

Support headless testing with monocle

parent f59c6bfb
Branches
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
<properties>
<skipUiTests>false</skipUiTests>
<headlessTests>false</headlessTests>
</properties>
<dependencies>
......@@ -167,6 +168,22 @@
</plugins>
</build>
</profile>
<profile>
<id>headless</id>
<properties>
<headlessTests>true</headlessTests>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testfx/openjfx-monocle -->
<dependency>
<groupId>org.testfx</groupId>
<artifactId>openjfx-monocle</artifactId>
<version>jdk-12.0.1+2</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
......@@ -179,8 +196,13 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipUiTests}</skipTests>
<systemPropertyVariables>
<headless>${headlessTests}</headless>
</systemPropertyVariables>
<argLine>
@{jaCoCoArgLine} --add-opens todolist.ui/todolist.ui=ALL-UNNAMED --add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
@{jaCoCoArgLine}
--add-opens todolist.ui/todolist.ui=ALL-UNNAMED --add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
......
......@@ -10,12 +10,29 @@ import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.ApplicationTest;
public class TodoAppTest extends ApplicationTest {
static void supportHeadlessTest() {
if (Boolean.getBoolean("headless")) {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
System.setProperty("java.awt.headless", "true");
}
}
@BeforeAll
public static void setupHeadless() {
supportHeadlessTest();
}
private TodoModelController controller;
@Override
......
......@@ -16,6 +16,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
......@@ -31,6 +33,11 @@ import todolist.json.TodoPersistence;
public class TodoListControllerTest extends ApplicationTest {
@BeforeAll
public static void setupHeadless() {
TodoAppTest.supportHeadlessTest();
}
private TodoListController controller;
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment