Runnning Tests Without Disrupting Your Desktop


Running FEST under Xvfb

By Jason Goodwin

In order to get the most value from an automated GUI testing tool like FEST-Swing, you'll want to have the ability to run your full suite of tests frequently. Doing so on your personal desktop can be very time consuming, as you must largely sit and watch while the tests run. If everything goes as planned, your tests will all pass and you need not have been watching it at all. If you're already running a CI (Continuous Integration) server like me (Hudson is my favorite), then the natural thing to do is run your GUI tests as part of your CI process. Even if you're not running a CI server, you would stand to benefit from not being forced to watch your tests run every time.

If you're running Linux, BSD, or any *NIX style operating system chances are that CI server probably doesn't even have X running, so how are you to run your GUI tests? Xvfb is the answer. Xvfb is a virtual frame buffer X server, meaning you don't need to have any video hardware, keyboard or mouse attached to the machine in question. If you're running Ubuntu or Debian, simply sudo apt-get (or aptitude) install xvfb. For other distributions (or OS) follow their normal process for installing packages.

Once installed, there are two ways to run Xvfb. The standard way is to run it as just a standalone server, manually running Xvfb like the main page suggests (e.g. Xvfb :1 -screen 0 1600x1200x24). Then, you set the DISPLAY=:1 environment variable to point your applications to that X server. The easier way, is to use xvfb-run. This wrapper makes it easy to start a new Xvfb server for each application you need to run, which lets you run multiple tests at a time without the applications conflicting with each other. If you currently run "ant test" to launch your FEST-Swing tests, simply run:

  xvfb-run -s "-screen 0 1280x1024x24" ant test

The screen options in my example are optional, I set them to ensure a reasonable size of display based on the application I was testing. If your application works fine in a smaller screen you can try omitting the screen options entirely and just execute "xvfb-run ant test"

Hopefully this simple idea will help free your desktop (and you) from spending time watching FEST work its magic.

See Also:




Javadocs

Reports

edit SideBar