Headless testing with JavaFx and TestFx

后端 未结 3 871
情书的邮戳
情书的邮戳 2020-12-16 22:01

I have a simple JavaFx application (Java 8) that has a unit test using TestFx. However, when the test is run, the application window starts up and the mouse is moved to do w

3条回答
  •  长情又很酷
    2020-12-16 22:36

    I would agree with KDK for using Monocle, since it does work as charm with Jenkins. I couldn't have reliable result from Xvfb on Jenkins. Below is the steps I took and works for me.

    Prepare Monocle

    You want to download Monocle from Monocle Github. It looks there is api change, so you would want to edit MonocleView.java with adding below method after download. I'm not sure what I should put in the method, but found it just works without implementing it.

    @Override
    protected int _getNativeFrameBuffer(long ptr) {
        // TODO Auto-generated method stub
        return 0;
    }
    

    Install Monocle

    Build the Monocle jar and put the jar into your JRE (under jre/lib/ext path)

    Run Monocle with Glass lib

    Below is my maven command used in jenkins, you will have interest on java runtime option portion.

    $ mvn clean install -Dtestfx.robot=glass -Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw
    

提交回复
热议问题