Cacio Testing Howto
November 4, 2011 2 Comments
Now that Cacio Testing is in a fairly usable shape, I thought it might be useful to write up some instructions how to get going with it, in case you want to test it.
You will need: Mercurial, Maven and JDK7
First clone the source code to your computer:
hg clone hg.openjdk.java.net/caciocavallo/ng/ cacio
Then build it using maven:
cd cacio
mvn clean install
Then in your project where you intend to use it, add this to the Maven dependencies:
<dependency>
<groupId>net.java.openjdk.cacio</groupId>
<artifactId>cacio-tta</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Finally, annotate your testcase with:
@RunWith(CacioTestRunner.class)
public class SimpleFESTTest {
...
}
Or if you used FEST’s GUITestRunner, you might want to use the equivalent:
@RunWith(CacioFESTRunner.class)
public class SimpleFESTTest {
...
}
Those steps should get you running with Cacio Testing. When you run a test with the above annotation, it should no more popup any windows or steal focus. I’d be happy if you could give it a try and report back how it goes, especially in case of problems.



Hi,
I did just try to use cacio-tta on OSX 10.6.8 with all updates and the Oracle provided JDK7 Developer preview b222, but cacio-tta test do not pass. I tried on command line and in eclipse, both produced the same problem:
java.lang.ClassCastException: net.java.openjdk.cacio.ctc.CTCGraphicsDevice cannot be cast to sun.awt.CGraphicsDevice
at sun.lwawt.macosx.LWCToolkit.createRobot(LWCToolkit.java:373)
at java.awt.Robot.init(Robot.java:138)
at java.awt.Robot.(Robot.java:96)
at org.fest.swing.util.RobotFactory.newRobotInPrimaryScreen(RobotFactory.java:35)
at org.fest.swing.image.ScreenshotTaker.(ScreenshotTaker.java:67)
at org.fest.swing.image.ScreenshotTaker.(ScreenshotTaker.java:60)
at org.fest.swing.junit.runner.FailureScreenshotTaker.(FailureScreenshotTaker.java:46)
at net.java.openjdk.cacio.ctc.junit.CacioFESTRunner.methodInvoker(CacioFESTRunner.java:87)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:243)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at net.java.openjdk.cacio.ctc.junit.CacioFESTRunner.run(CacioFESTRunner.java:65)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
It seems there are somme assumptions made in the LWAWT toolkit of the OSX port. I would gladly dig into the problem if this was not currently way out of my league.
Loïc: Try running the test with the options -Dawt.toolkit=net.java.openjdk.cacio.ctc.CTCToolkit -Djava.awt.graphicsenv=net.java.openjdk.cacio.ctc.CTCGraphicsEnvironment on the java command line.