question

ChrisB avatar image
ChrisB asked ChrisB posted

Java Swing testing on a headless Linux box (iTestRT)

Can we run Java Swing tests from iTestRT on a LInux machine with no display set up?

 

Thanks,

Chris

iTestGUI Testing(Web-Java Swing-etc)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
PreetS avatar image
PreetS answered PreetS posted

No. Maybe you can forward the Display to another machine?

8 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tlawall avatar image tlawall commented ·

Preet,

 

Chris posted this originally for me, so I'll ask some follow up questions now that I've had a chance to play with it.

 

I've been able to get some swing tests running headlessly in Xvfb and XVnc using itestcli and the -g option.  On both occasions, I set the display variable to be the virtual desktop's server instance prepended on the command line.  Something like this:

 

DISPLAY=:1.0 itestcli -g -w /opt/etf_workspace/ project://my_project/test_cases/SwingSetTabCapture.fftc

 

This worked fine.  Now there's two questions I have:

 

Can iTestRT run gui apps headlessly by forwarding the display to this virtual server, AND if not, does the -g flag on itestcli burn up a developer license if it's being run on an execution box with an execution license?  Ultimately that's the goal, to run these regression tests on the execution servers that have the unlimited execution licenses, instead of burning up developer licenses to run the regressions.

0 Likes 0 ·
tlawall avatar image tlawall tlawall commented ·

Does iTestRT have the capability to run Swing automation tests, even if they're not headless?  I'm doing this (on my desktop, without messing with the DISPLAY env variable):

 

itestrt --itar file:/opt/ --test project://my_project/test_cases/SwingSetTabCapture.fftc

 

And getting this:

 

Fail     session ma t2       1     1      main       The application "com.fnfr.svt.applications.java.swing" is unknown

0 Likes 0 ·
ChrisB avatar image ChrisB tlawall commented ·

 

With 4.0.2 it won't work.

0 Likes 0 ·
PreetS avatar image PreetS ChrisB commented ·

Swing support for iTestRT will be available soon. It is not supported at the moment

0 Likes 0 ·
tlawall avatar image tlawall PreetS commented ·

I know this might not get an answer, but what will it look like?  Does this mean that I can forward it's display to a vncserver or xvfb instance?  If so, then we've solved the problem I have.

 

Thanks!

 

T.

0 Likes 0 ·
PreetS avatar image PreetS tlawall commented ·

Yes you will be able to forward the display. You wont need to pass it -g option either. 

0 Likes 0 ·
tlawall avatar image tlawall PreetS commented ·

 

So for the sake of future reference, I figured I'd put a few notes here for when that support does arrive:

 

If you're unfamiliar with exporting a display in Xwindows, you might want to go read up on it elsewhere, as it's far too much for me to dig into in a forum post (and i'm likely to get stuff wrong). XWindow Design is a good start for understanding some of the basics, but really you aught to look it up in Google using the keywords of "how to export X DISPLAY".

 

Headless test execution of a java swing application on a Linux box relies on a few predicates:

 

  •  you have to have the X server libraries installed.  Even though you're using a virtual server (either Xvnc or Xvfb) you still need the libraries for the application (in this case, the java vm that runs iTestRT and the Swing app in test).  This usually isn't a problem these days, because most distros of Linux install the X server by default.  I mention it just in case you have a server install that is stripped down to only the essentials.
  • you need a virtual X server, either in the form of Xvfb (which doesn't have live viewing capabilities, but allows screen capture easily) or Xvnc (which you can attach to with a vnc client and view what's happening, and take control if need be).  I prefer Xvnc for the live viewing aspect.

After you start up the virtual server, you'll either specify a display number or you'll have received one if you didn't.  This is the number you'll pass on to iTestRT/itestcli via the DISPLAY environment variable.  All you need to do is specify it before you run the itestcli/iTestRT command:

 

 

DISPLAY=:2.0 itestcli -g -w <workspace> <testcase>

 In this example, the display we wished to export to was "2", and it's specified by ":2.0".  The ".0" specifies the screen, but since this is a virtual framebuffer, you usually only have one screen.

 

This is all I needed to get itestcli running in a Xvnc server doing some automation on my Swing GUI.  Hopefully this is helpful for others.

 

T.

 

0 Likes 0 ·
PreetS avatar image PreetS tlawall commented ·

Thanks for posting this info tlawall

It would be useful for anyone else trying to set up their displays. 

 

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.