We have some UI test cases which we are currently invoking manually on our Linux machine (with Gnome enabled).  We login to the machine and run the below command:

java -jar test_case.jar

to invoke the test case. This opens the browser and performs the application test, and then writes the logs and quits.

Now I am planning to automate this in a Jenkins Pipeline Job.  But I am not sure what would be the right way to do this, because I believe Jenkins Pipeline Job gets executed in a pseudo terminal, whereas I believe the above command should be executed in a Gnome console.

Is there a way to automate this scenario?

  • 1
    You either need a "headless" browser or an X11 display available for the test process: e.g. start a Xvfb :1 & and set export DISPLAY=:1 before starting the java process. Another option is using Xvnc to be able to connect remotely and see the test runs. – Ramon Poca Dec 17 '18 at 19:53
  • It is a virtual machine. Do I need to install any additional packages to start Xvfb ? – Parthasarathy Venugopal Dec 18 '18 at 3:15

Xvfb (X Virtual Frame Buffer) can be used for this purpose. It allows you to have a display that exists only in-memory, so that tests/operations with graphical dependencies can be completed without actually using a GUI.

On CentOS, you can install Xvfb from the core CentOS repository with yum:

yum install xorg-x11-server-Xvfb

Once Xvfb is installed, prefix your command with xvfb-run to use it:

xvfb-run java -jar test_case.jar

xvfb-run is a wrapper command that does a few useful things. First, it initializes an Xvfb display and passes it to your command for execution. Once the command runs to completion, the display is also gracefully shut down.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.