Friday, August 12, 2011

UISpec4J with Fitnesse Test POS

As usual I come running into here whenever something like this blows me away. UISpec4J is used to test Java GUI Panels,and I discovered it to test our JavaPOS. Been able to integrate it into Fitnese, which was another thing that blew me away so wicked that i forgot to come back here to tell you about it in time. Below is what our JavaPOS looks like and imagine having to do a real test you cannot avoid but getting a program to click on it like a touchscreen would:



To get UISpec4J incorporated into your suite of testing code is just a matter of introducing its interface like I did below:
import org.uispec4j.UISpec4J;
import org.uispec4j.UISpecTestCase;

public abstract class ModelLogin extends UISpecTestCase {
static {
UISpec4J.init();
}
And then in my calling test class that extends ModelLogin, I implement the getMainWindow() method:
public Window getMainWindow() {
cnt = false;
final Window[] result = new Window[3];
WindowInterceptor.init(new MainClassTrigger(PosApplication.class, new
String[0]))
.process(new WindowHandler(){
public Trigger process(Window window) throws Exception{
result[0]=window;
window.getButton("Ok").click(); //1st window login preset to SuperUser
return window.getButton("Ok").triggerClick(); //2nd window Client is preset to GardenAdmin and StoreCentral
}
})
.process(new WindowHandler(){
public Trigger process(Window window) throws Exception{
result[1]=window; //2 button pressed, with values passed from FitnesseStory script
window.getButton(selected).click();
window.getTextBox("BPartner").setText(bpartner);
window.getTextBox("BPartner").pressKey(Key.ENTER);
window.getButton("Plus").click();
window.getButton(selected2).click();
return window.getButton("Payment").triggerClick(); //
}
})
.process(new WindowHandler(){
public Trigger process(Window window) throws Exception{
result[2]=window;
return window.getButton("Ok").triggerClick(); //
}
})
.run();
return result[1];
}
The final output is resolved by the Fitnesse layer into a wiki-styled webpage:



(right click on it to View a fuller Image)

As you can see the above is done by Fitnesse and the reason why it is also very mind-blowing. All this thanks to Free Source. I am making a nice living out of it, and it feels great to make a contribution back here and in my ADempiere project as a powerful QA suite.

0 comments:

 
SourceForge.net Logo