Monocle Headless Platform已由Java Runtime的最新版本(类文件版本53.0)进行编译

时间:2019-09-26 14:09:20

标签: java headless openjfx testfx monocle

我正在用Junit5和TestFX编写应用程序测试。我的意图是,主测试类在每次测试后都会重新启动应用程序,所有测试应无头运行。

这是我的考试班:

public class MainTest extends ApplicationTest implements FxRobotInterface {

      Logger loggerGuiTesting = LoggerManager.getInstance().getLogger(LoggerType.GUI_TESTING);

      public static final boolean HEADLESS = true;

      private Stage primaryStage = AppMainClass.getStage();

      @BeforeAll
      public static void setupSpec() throws Exception {
        if (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");
        }
          FxToolkit.registerPrimaryStage();
    }

    @BeforeEach
    public void setUp() throws Exception {      
      FxToolkit.setupApplication(AppMainClass.class);
    }

    private Scene scene;

    @Override
    public void start(final Stage stage) {

        this.primaryStage = stage;

        this.primaryStage.show();

        this.scene = this.primaryStage.getScene();

        this.loggerGuiTesting.log(Level.INFO, "App starts!");
    }

   @AfterAll
   public void endApplication() {
      new ExitGuiTest().run(); // That's my internal test framework
   }

   @Test
   public void atestIfOpeningScreenIsThere() {
    verifyThat("#imageViewSplashScreenLogo", NodeMatchers.isNotNull());
    verifyThat("#progressBarSplashScreen", NodeMatchers.isNotNull());
    verifyThat("#labelSplashScreenVersion", NodeMatchers.isNotNull());
    verifyThat("#labelSplashScreenDate", NodeMatchers.isNotNull());
    this.loggerGuiTesting.log(Level.INFO, "testIfOpeningScreenIsThere, succeeded!");
}

   @Test
   public void btestIfRadioButtonOneExist() {
    assertThat("#sourcesOneRadioButton", is("#sourcesOneRadioButton"));
    this.loggerGuiTesting.log(Level.INFO, "testIfRadioButtonOneExist, succeeded!");
    }

    @Test
    public cnextTest() {
        new StartAnotherGuiTest().run();
        this.loggerGuiTesting.log(Level.INFO, "anotherTest, succeeded!");
    }

}

我运行测试,此消息出现错误代码:

  

java.lang.RuntimeException:java.lang.UnsupportedClassVersionError:   com / sun / glass / ui / monocle / HeadlessPlatform已由更多   Java Runtime的最新版本(类文件版本53.0),   Java Runtime的版本最多只能识别类文件版本   52.0

     

java.lang.UnsupportedClassVersionError:   com / sun / glass / ui / monocle / HeadlessPlatform已由更多   Java Runtime的最新版本(类文件版本53.0),   Java Runtime的版本最多只能识别类文件版本   52.0

     

java.lang.IllegalStateException:工具包未初始化

我的build.gradle看起来像这样:

  

依赖性{
   实施项目(':A')
  实施项目(':B')
  实施项目(':C')
  实施项目(':D')
  实施项目(':E')
  实施项目(':F')   实现fileTree(dir:'lib',包括:' .jar')
  实现fileTree(dir:'../A/lib',包括:'
.jar')
  实现fileTree(dir:'../A/lib/gson',包括:' .jar')
  实现fileTree(dir:'lib /',包括:'
.jar')
  实现fileTree(dir:'lib /',包括:' .jar')
  实现fileTree(dir:'../C/C1/framework/libraries',包括:'
.jar')
  实现fileTree(dir:'../C/C1/framework',包括:'*。jar')       api'org.apache.commons:commons-math3:3.6.1'       api'junit:junit:4.12'       api'junit:junit:4.13-beta-3'

 if(JavaVersion.current() >= JavaVersion.VERSION_11){      
     

implementation(“ org.openjfx:javafx-base:11.0。+:win”,
  “ org.openjfx:javafx-graphics:11.0。+:win”,
  “ org.openjfx:javafx-controls:11.0。+:win”,
  “ org.openjfx:javafx-media:11.0。+:win”,   “ org.openjfx:javafx-fxml:11.0。+:win”,   “ org.openjfx:javafx-swing:11.0。+:win”,
  “ org.openjfx:javafx-web:11.0。+:win”)         }

// Use JUnit test framework    
// This dependency provides the public API for writing tests and extensions       
      testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: >'5.4.2'     
     

testImplementation组:'org.junit.jupiter',名称:'junit-jupiter-api',版本:'5.4.2'
    testImplementation组:“ org.junit.jupiter”,名称:“ junit-jupiter-params”,版本:“ 5.4.2”
  testImplementation组:“ org.junit.jupiter”,名称:“ junit-jupiter-migrationsupport”,版本:>“ 5.4.2”   testRuntimeOnly组:“ org.junit.jupiter”,名称:“ junit-jupiter-engine”,版本:“ 5.4.2”
  testRuntimeOnly组:“ org.junit.vintage”,名称:“ junit-vintage-engine”,版本:“ 5.4.2”   testImplementation组:“ org.junit.platform”,名称:“ junit-platform-engine”,版本:“ 1.5.1”
  testImplementation组:“ org.junit.platform”,名称:“ junit-platform-launcher”,版本:“ 1.5.1”

testCompileOnly group: 'junit', name: 'junit', version: '4.13-beta-3'

testCompileOnly group: 'junit', name: 'junit', version: '4.12'

testImplementation group: 'org.testifyproject.junit4', name: 'junit4-core', version: '1.0.6'

//This dependency provides TestFX
testImplementation group: 'org.testfx', name: 'testfx-junit5', version: '4.0.16-alpha'
testImplementation group: "org.testfx", name: "testfx-core", version: "4.0.16-alpha"
testImplementation group: "org.testfx", name: "testfx-junit", version: "4.0.16-alpha"

testImplementation group: 'org.testfx', name: 'testfx-legacy', version: '4.0.8-alpha'

// This dependency runs tests in JUnit 5, 4, 3 
testRuntimeOnly(
      'org.junit.jupiter:junit-jupiter-engine:5.4.2',
        'org.junit.vintage:junit-vintage-engine:5.4.2',
         'org.testfx:openjfx-monocle:jdk-9+181.1'

)
                                            }
     

测试{       useJUnitPlatform()

useJUnit()
  jvmArgs "-Dheadless=${project.hasProperty('headless') ? project.headless : false}"

testLogging {         
   events "passed", "skipped", "failed"   
}       }

我当前正在使用jdk1.8.0_201。我不允许续订Java版本。

0 个答案:

没有答案