Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
0787fccc
Commit
0787fccc
authored
4 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Trying to use TestFX for RegionChooser.
parent
3997d700
Pipeline
#6954
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pom.xml
+25
-0
pom.xml
src/test/java/eu/simstadt/regionchooser/RegionChooserGUITest.java
+83
-0
.../java/eu/simstadt/regionchooser/RegionChooserGUITest.java
with
108 additions
and
0 deletions
+108
-0
pom.xml
+
25
-
0
View file @
0787fccc
...
@@ -45,6 +45,31 @@
...
@@ -45,6 +45,31 @@
<artifactId>
vtd-xml
</artifactId>
<artifactId>
vtd-xml
</artifactId>
<version>
2.13.4
</version>
<version>
2.13.4
</version>
</dependency>
</dependency>
<!-- Test dependencies for JavaFX -->
<dependency>
<groupId>
org.testfx
</groupId>
<artifactId>
testfx-core
</artifactId>
<version>
4.0.16-alpha
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.testfx
</groupId>
<artifactId>
testfx-junit5
</artifactId>
<version>
4.0.16-alpha
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.testfx
</groupId>
<artifactId>
openjfx-monocle
</artifactId>
<version>
8u76-b04
</version>
<!-- jdk-11+26 for Java 11, jdk-9+181 for Java 9, 8u76-b04 for Java 8 -->
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.hamcrest
</groupId>
<artifactId>
hamcrest
</artifactId>
<version>
2.1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
This diff is collapsed.
Click to expand it.
src/test/java/eu/simstadt/regionchooser/RegionChooserGUITest.java
0 → 100644
+
83
-
0
View file @
0787fccc
package
eu.simstadt.regionchooser
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
java.nio.file.Paths
;
import
java.util.concurrent.TimeoutException
;
import
java.util.prefs.Preferences
;
import
org.junit.jupiter.api.AfterAll
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.testfx.api.FxRobot
;
import
org.testfx.framework.junit5.ApplicationExtension
;
import
org.testfx.framework.junit5.Start
;
import
javafx.application.Platform
;
import
javafx.stage.Stage
;
@ExtendWith
(
ApplicationExtension
.
class
)
class
RegionChooserGUITest
{
private
static
final
String
TEST_REPOSITORY_PATH
=
Paths
.
get
(
"../../TestRepository"
).
toAbsolutePath
().
toString
();
private
static
String
originalRepository
;
private
static
Preferences
userPrefs
=
Preferences
.
userRoot
().
node
(
"/eu/simstadt/desktop"
);
private
FxRobot
robot
;
@BeforeAll
/**
* This method makes sure that the JavaFX/TestFX tests are run in headless mode. They should work on Linux Server,
* thanks to https://github.com/TestFX/Monocle
*
* Alternatively, in order to force headless mode from Maven:
*
* mvn clean package -Dtestfx.robot=glass -Dtestfx.headless=true -Dprism.order=sw -Dprism.text=t2k
*
* More info:
*
* https://stackoverflow.com/questions/27403410/headless-testing-with-javafx-and-testfx
* https://medium.com/@danielnenkov/run-testfx-tests-on-jenkins-running-on-ec2-d68197e10e2b
*/
private
static
void
setupHeadlessTests
()
{
// System.setProperty("testfx.robot", "glass");
// System.setProperty("testfx.headless", "true");
// System.setProperty("prism.order", "sw");
// System.setProperty("prism.text", "t2k");
}
@BeforeAll
private
static
void
setRepositoryToTestRepository
()
{
originalRepository
=
userPrefs
.
get
(
"RECENT_REPOSITORY"
,
TEST_REPOSITORY_PATH
);
userPrefs
.
put
(
"RECENT_REPOSITORY"
,
TEST_REPOSITORY_PATH
);
}
@AfterAll
private
static
void
resetRepositoryToOriginalRepository
()
{
userPrefs
.
put
(
"RECENT_REPOSITORY"
,
originalRepository
);
}
/**
* Will be called with {@code @Before} semantics, i. e. before each test method.
*
* @param stage - Will be injected by the test runner.
*/
@Start
private
void
start
(
Stage
stage
)
{
Platform
.
runLater
(()
->
new
RegionChooserFX
().
start
(
stage
));
}
/**
* @param robot - Will be injected by the test runner.
* @throws InterruptedException
* @throws TimeoutException
*/
@Test
void
testClickOnRegionChooser
(
FxRobot
testRobot
)
throws
InterruptedException
,
TimeoutException
{
this
.
robot
=
testRobot
;
System
.
out
.
println
(
robot
.
window
(
0
).
getScene
());
System
.
out
.
println
(
robot
.
lookup
(
"#RegionChooserBrowser"
).
query
());
// WaitForAsyncUtils.waitFor(30, TimeUnit.SECONDS, () -> !runButton.isDisabled());
robot
.
clickOn
(
"TEST"
);
assertTrue
(
false
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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