如何在无头环境中测试JavaFX的2?(How to test JavaFX 2 in a head

2019-06-27 14:09发布

我想针对Java 7u6与集成的JavaFX 2.2运行JavaFX的2个应用自动化测试。 为此,我已经建立并集成Jemmy3和JemmyFX到我的构建环境。 一个简单的烟雾测试所有相关操作系统上运行。

作为下一个步骤,我想作为持续部署过程的一部分运行测试。 由于目前的CI服务器在openSUSE,这不是正式的JavaFX支持运行时,我已经在虚拟机并安装GTK2设立一个Ubuntu Server安装。
为了弥补缺乏一个完全成熟的窗口系统的,我已经试过两个的XvncXvfb来运行测试,但无济于事。

Xvnc的 ,测试失败

Prism ES2 Error - nInitialize: glXChooseFBConfig failed

而在Xvfb来 ,他们给我

Xlib:  extension "RANDR" missing on display ":10".

一个博客文章建议安装gtk-engines-pixbuf缓解第二个问题,但这只是改变了错误信息显示的数量。

现在,我召唤StackOverflow上的JavaFX的知识和要求

  • 你知道如何解决上述的错误?
  • 你成功运行(无头)CI服务器上一个JavaFX 2测试或机器人互动?
  • 你是如何配置系统才能正常工作?

Answer 1:

Support for (headless) CI server testing of JavaFX is not available until JavaFX 8.

Answer based on information in these JavaFX issue tracking records:

  • JDK-8088651 "Headless Glass toolkit needs to be connected to Quantum and Prism unit tests"
  • JDK-8091286 "Quantum needs headless and headful tests").

Update Jan 8, 2015

The linked JavaFX issue tracking records were not implemented for Java 8 and have been reassigned to Java 9.

Java 8 source code currently includes a minimal rendering engine named Monocle which provides Headless rendering (and rendering for various other target platforms) for JavaFX components. I have never used Monocle and cannot provide detailed instructions on how to use it for headless rendering. I believe to use Monocle, you currently need to perform a custom build of JavaFX from source (as I think Monocle is usually only shipped in embedded JavaFX versions, which is not the standard JavaFX version which ships with the desktop Java runtime and JDK environments).

Information on Monocle is available on the JavaFX wiki.

Although, headless rendering is provided by Monocle, I do not think that using Monocle to perform headless rendering is officially supported by Oracle (though i don't think headless rendering of JavaFX in any form is officially supported, so I guess if Monocle works well for you, by all means use it).

The headless rendering in Monocle is a software rendering implementation so execution of some graphic primitives may be slower than the standard hardware accelerated operation of JavaFX in a desktop environment.

There may be other methods of allowing JavaFX to run in a headless environment that I am not aware of.

If in doubt, ask the JavaFX developers on the openjfx-dev mailing list.

If you are running under Linux, using Xvfb as suggested by Jan Zarnikov's answer is probably a good solution and is likely preferable to using Monocle.



Answer 2:

我有一个类似的问题 - 在使用Maven无头环境中运行JUnit测试。

我们不使用JemmyFX。 我们只是使用类似一个JUnit的规则非常简单的测试: https://gist.github.com/andytill/3835914 (这需要使用Platform.runLater(代码...))

JavaFX的(与JDK提供1.7.0-21)的最新版本似乎Xvfb来是工作在Ubuntu 12.04没有运行的Xserver:

  1. Xvfb :99
  2. DISPLAY=:99 mvn clean install


文章来源: How to test JavaFX 2 in a headless environment?