Fest For Beginners – Testing Yourself

By this point you should be able to set up Fest, open your application and access the various components on your user interface. If done right you should have even set up an example that opens a native using the user interface as if a user has performed the actions.
Now, lets test this program, shall we.

How am I looking?

If you are testing search and highlighting functionalities like I have been you will proberly want to compare the look of the window at given times after given functionality has been called. These tests are a great way of testing what the user output will be. This is relatively easy to achieve.
First we need to get access to our BasicRobot (we are calling this object robotf). The BasicRobot has access to a method that will create an image based on screen coordinate passed to it.

robotf.createScreenCapture(Rectangle screenRect);

Using this method we can take a picture of the screen when we have triggered the functionality we wish to test.
Next we compare this to a baseline created in the same way that we know to be correct. First compare the the file size of the created image and the baseline image. If they are different then the files are different.
If you are incredibly unlucking or believe that the image may have the same size but still have difference (this is incredibly rare) you need to run through the image pixel at a time comparing the RGB values of each pixel.

Spot the difference

So the two images look incredibly similar. How do you know where the difference is?
Well first of all get the Graphics2D object for the image created by your test. Now for every pixel in the created image that is not the same as the corresponding pixel in the baseline image set the pixel to cyan. If the pixel is already cyan set it to a  magenta pixel. Or your could draw the inverse color of the pixel. Whatever technique you would prefer to use to show the difference, change the pixels to a different color to make them stand out compared to the baseline. This can be done as follows.

BufferedImage baseline;
BufferedImage testImage;

/*Create test image and load baseline image here*/
for (int x=0;x

Going on beyond this is now up to you. If you wish to try Fest yourself it can be found at http://fest.easytesting.org/

This post is part of our “Testing Articles Index” in these articles we provide a guide to Testing.

Related Posts:

The following two tabs change content below.
Kieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He often has no idea what to write in his blog posts but tries his hardest to make them interesting and entertaining, he also makes no excuses for his odd sense of humor.
KieranF

About Kieran France

Kieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He often has no idea what to write in his blog posts but tries his hardest to make them interesting and entertaining, he also makes no excuses for his odd sense of humor.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>