What is Fest
Recently I have improved the highlighting of PDF files in our Java PDF viewer. With this improvement I have had to find a way to test the highlights and any future improvements we make to the highlights.
For this reason I have started using a test library called Fest. Fest is a set of APIs that can be used to test java applications which include api to simulate user input and interaction with a user interface. In other words instead of me testing a series of files, performing the same actions on each file, by hand, everytime we want to make a build I can have a computer do it for me.
One of the major advantages I found of performing tests in this way is that calling various function calls from a test running at a lower level than the user can interact is completely ignoring a section of code that may be including other methods or variables that aren’t called at the lower level. By testing using fest we can compare output across a known working version to ensure everything works correctly for the end user without having to dedicate a team members time to sitting there and working through the same test for hours.
Have you convinced you that Fest is very useful for regression testing?
First steps with Fest
In order for the way I have set up Fest to work you will need to have set unique names set to each gui component that you will be using.
Once you have code that will set up and open your application you need to create a BasicRobot object and a FrameFixture object. This can be done as follows.
BasicRobot robotf = (BasicRobot)BasicRobot.robotWithCurrentAwtHierarchy(); //mainFrame is the name of a frame component. FrameFixture frame = WindowFinder.findFrame("mainFrame"). withTimeout(5000).using(robotf);
Now you have these two object you will be able to simulate user input using FrameFixture. In order to have Fest trigger events as a user would we can call methods named after the various user interface types such as button, checkBox, scrollPane, radioButton…
These methods take a string value that should be the unique name of the component you wish to trigger. This will return a fixture that can interact with the user interface as the user would using methods like click.
These are the initial concepts that you need to keep in mind if you wish to use Fest for your own tests. If you wish to try Fest yourself it can be found at http://fest.easytesting.org/
I’ll be covering it in more detail in my coming articles.
IDRsolutions develop a Java PDF library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.