Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ole Hermann Bakka
todo-list-example
Commits
ef1306b8
Commit
ef1306b8
authored
Nov 03, 2021
by
Hallvard Trætteberg
Browse files
Support headless testing with monocle
parent
f59c6bfb
Changes
3
Hide whitespace changes
Inline
Side-by-side
todolist/fxui/pom.xml
View file @
ef1306b8
...
...
@@ -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>
...
...
todolist/fxui/src/test/java/todolist/ui/TodoAppTest.java
View file @
ef1306b8
...
...
@@ -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
...
...
@@ -26,7 +43,7 @@ public class TodoAppTest extends ApplicationTest {
stage
.
setScene
(
new
Scene
(
root
));
stage
.
show
();
}
private
TodoPersistence
todoPersistence
=
new
TodoPersistence
();
@BeforeEach
...
...
todolist/fxui/src/test/java/todolist/ui/TodoListControllerTest.java
View file @
ef1306b8
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment