Cacio for UI testing

I became quite a fan of FEST recently. It’s a very good framework for unit testing user interfaces written in Java/Swing. However, I always struggled to get it to run reliably on a continuous build/test server. As far as I could figure out, this is due to the following reasons:

  • UI tests are inherently using the computer’s desktop. If more than two test processes run in parallel or if a user is interacting with the same desktop, things get messed up.
  • Many UI stacks are behaving asynchronously. I.e. when calling drawLine() and the call returns, there is no guarantee that the line has actually been drawn, the drawing command can still be waiting in paint command queue.

On Unix, both problems can be addressed to a certain degree by using Xvfb and enabling some debug flags on the X server to perform synchronous roundtrip communication with the X server. I tried that, and it still did not give me 100% isolation of tests as I wanted. On a Windows server, this is a complete nightmare (as is to be expected).

Last week we implemented a solution based on Cacio. This is a Java graphics backend that let’s Java not draw on the computer’s screen at all, and instead render into an offscreen buffer. Mouse and keyboard events are driven solely by java.awt.Robot (which is exactly what you need for testing UIs). Each testing process can have it’s own virtual screen (or even multiple virtual screens for testing multiscreen applications). The size of the screen can be configured. Even screenshots can be taken (using java.awt.Robot). Using this framework, each unit test runs fully isolated from other tests and from user or system interaction, thus making them perfectly reliable. The implementation is done 100% in Java, and comes as a JAR file that you simply plug into your classpath as any other testing framework.

Mario and I are in the process of setting up our own little company. We will extend the website soon, and when we’re at it, setup a project website for Cacio and IcedRobot as well. The Cacio testing framework (or if you prefer more buzz-fluffy words, Cacio Testing Cloud 😉 ) will be our first supported product. So if you are interested in using it in production environment and need support for doing so, you are welcome to contact us.

Advertisements

5 Responses to Cacio for UI testing

  1. I’m interested in cacio itself. It sounds like it’s already in JDK7, can you point me to the api?

  2. Roman Kennke says:

    It’s not part of JDK7. We currently don’t have an uptodate project webpage nor an API documentation. We will set this up shortly. If you are interested, you can fetch the sourcecode http://hg.openjdk.java.net/caciocavallo/ng/ .

  3. Pingback: Reliable UI testing using FEST Swing and Cacio « Roman Kennke's Blog

  4. Pingback: Keyboard mapping support for Cacio Testing « Roman Kennke's Blog

  5. Stefan Lecho says:

    I’ve added

    net.java.openjdk.cacio
    cacio-tta
    1.2
    test

    and

    org.apache.maven.plugins
    maven-surefire-plugin
    2.12.3

    false
    net.java.openjdk.cacio.ctc.CTCToolkit
    net.java.openjdk.cacio.ctc.CTCGraphicsEnvironment

    in my pom.xml.

    When running locally, I’m getting results.
    When running on a Jenkins server, i’m gettin an error: Could not find class: net.java.openjdk.cacio.ctc.CTCGraphicsEnvironment.

    Could you please help me solving this issue ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: