JUnit, NetBeans RCP, Testing

Delicious JellyTools for NetBeans functional testing


Yesterday I had the pleasure of writing some functional tests (for an in house IDE) using JellyTools, NetBeans’ extension to the Jemmy testing framework. The testing APIs offered by Jelly and Jemmy are very intuitive and you can get your GUI test up and running in minutes.

Jemmy provides various types of Swing/AWT  ‘operators‘ that can be used to manipulate GUI components. Examples for Jemmy operators include JTreeOperator, JPopupMenuOperator, JCheckBoxOperator etc.

Jelly extends these and provide NetBeans platform specific convenience operators such as TopComponentOperator, OutputTabOperator, ProjectsTabOperator etc.

In my case, my functional test needed to test my (custom) IDEs build project functionality.

public void testIDEBuild() {
   //utility method to open a project, code not shown here
   openProject(PROJ_NAME); 
   //open the IDEs output window
   new OutputWindowViewAction().perform(); 
   //get a handle to the Projects tab in NetBeans
   ProjectsTabOperator projects = new ProjectsTabOperator();
   //get a handle to the project tab's explorer tree
   JTreeOperator tree = new JTreeOperator(projects);
   //find the node that contains the RMB action 'Build'
   TreePath path = tree.findPath(PROJ_NAME+"| My Applications"); 
   //get a popmenu operator
   JPopupMenuOperator menu = new JPopupMenuOperator(tree.callPopupOnPath(path));   
   //call the 'Build' action
   menu.pushMenuNoBlock("Build");    
   //get the output tab containing 'proj-build' ANT output
   OutputTabOperator outputTabOp = new OutputTabOperator("proj-build"); 
   //give 2 mins for building
   outputTabOp.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 120000);
   //check for "BUILD SUCCESSFUL" if not the test fails
    outputTabOp.waitText("BUILD SUCCESSFUL"); 
}

For information on how to get started with NetBeans testing and how to write JellyTools tests refer the following links.

Advertisements

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