Java 找不到TestFx无头MonoclePlatformFactory
我尝试使用JavaFX+Maven+TestFX(无头) 我遵循本教程以无头模式启用测试 我的pomJava 找不到TestFx无头MonoclePlatformFactory,java,javafx,testfx,Java,Javafx,Testfx,我尝试使用JavaFX+Maven+TestFX(无头) 我遵循本教程以无头模式启用测试 我的pom <groupId>com.bega</groupId> <artifactId>Chronos</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>Chronos</name&g
<groupId>com.bega</groupId>
<artifactId>Chronos</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Chronos</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.bega.chronos.MainApp</mainClass>
</properties>
<organization>
<!-- Used as the 'Vendor' for JNLP generation -->
<name>dazzd</name>
</organization>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>xml</format>
</formats>
<check>
</check>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<threadCount>1</threadCount>
<systemPropertyVariables>
<glass.platform>Monocle</glass.platform>
<monocle.platform>Headless</monocle.platform>
<prism.order>sw</prism.order>
</systemPropertyVariables>
<additionalClasspathElements>
<additionalClasspathElement>${java.home}/lib/ext/jfxrt.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
<version>8.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-core</artifactId>
<version>4.0.13-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit</artifactId>
<version>4.0.13-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>openjfx-monocle</artifactId>
<version>1.8.0_20</version>
<scope>test</scope>
</dependency>
</dependencies>
ChronoTest.java
public class ChronoTest extends ApplicationTest {
@BeforeClass
public static void setupHeadlessMode() {
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");
}
//bundle = ResourceBundle.getBundle("Bundle");
}
@Before
public void beforeEachTest() throws Exception{
FxToolkit.setupApplication(MainApp.class);
}
@Test(expected = FxRobotException.class)
public void testAffihage(){
verifyThat("#emma", hasText("Emmanuel"));
}
@After
public void afterEachTest() throws TimeoutException{
FxToolkit.hideStage();
release(new KeyCode[]{});
release(new MouseButton[]{});
}
public <T extends Node> T find(final String query){
return (T) lookup(query).queryAll().iterator().next();
}
未能加载玻璃工厂类
你知道吗
public class ChronoTest extends ApplicationTest {
@BeforeClass
public static void setupHeadlessMode() {
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");
}
//bundle = ResourceBundle.getBundle("Bundle");
}
@Before
public void beforeEachTest() throws Exception{
FxToolkit.setupApplication(MainApp.class);
}
@Test(expected = FxRobotException.class)
public void testAffihage(){
verifyThat("#emma", hasText("Emmanuel"));
}
@After
public void afterEachTest() throws TimeoutException{
FxToolkit.hideStage();
release(new KeyCode[]{});
release(new MouseButton[]{});
}
public <T extends Node> T find(final String query){
return (T) lookup(query).queryAll().iterator().next();
}
java.lang.ClassNotFoundException: com.sun.glass.ui.monocle.MonoclePlatformFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
at com.sun.glass.ui.Application.run(Application.java:146)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)