0

运行以下代码段(在 Eclipse 中设置 JDK 7):

import javafx.scene.Scene;
import javafx.stage.Stage;

import org.junit.Test;
import org.testfx.framework.junit.ApplicationTest;

public class BasicTestFxTest extends ApplicationTest 
{
    @Override
    public void start(Stage stage) throws Exception 
    {
        Scene scene = new Scene(null, 800, 600);
        stage.setScene(scene);
        stage.show();
    }

    @Test
    public void test()
    {
        System.out.println("This is not a test.");
    }
}

导致以下异常:

java.lang.UnsupportedClassVersionError: org/testfx/framework/junit/ApplicationTest : java.lang.ClassLoader.defineClass1(Native Method) at java.security 的 java.lang.ClassLoader.defineClass(Unknown Source) 不支持 major.minor 版本 52.0 .SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net .URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc。 Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang。ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader。 access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader .findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.eclipse.jdt .internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:685) 在 org.eclipse.jdt.internal.junit.runner。RemoteTestRunner.loadClasses(RemoteTestRunner.java:421) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( RemoteTestRunner.java:675) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java: 192)主要(RemoteTestRunner.java:192)主要(RemoteTestRunner.java:192)

注意:我使用的是 testfx-core 和 testfx-junit 4.0.1-alpha。

4

1 回答 1

1

它已在版本 4 中修复(TestFX 4.0.0-alpha - February 27, 2015 - #103)但版本 4 处于 alpha 阶段

(修复)服务:修复对 Java 7 和 JavaFX 2 的兼容性。(#103)- 1 次提交

问题:https ://github.com/TestFX/TestFX/pull/103

于 2016-10-24T14:05:31.773 回答