Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "RapUITesting"

(initial page)
 
Line 1: Line 1:
{{attention}}
+
=<font color="red">WORK IN PROGRESS</font>=
  
 
| [[RAP|RAP wiki home]] | [http://eclipse.org/rap RAP project home] |
 
| [[RAP|RAP wiki home]] | [http://eclipse.org/rap RAP project home] |

Revision as of 12:00, 29 May 2007

WORK IN PROGRESS

| RAP wiki home | RAP project home |

Writing UI Tests for RAP applications

This document will describe one way how to do UI tests for you RAP applications. For this way, we use the combination of JUnit, Selenium and Selenium RC to have automatic UI tests which can be integrated into your JUnit testsuite.

We will provide a simple example application to demonstrate the usage of the several tools.

Requirements

If you don't have it, you need at least these files in order to follow the tutorial:

Extract these files in a directory of your choice.

Creating the sample application

First we need something to test. Therefor I put together a little example application to demonstrate the UI testing approach.

Just create a new plugin project, add org.eclipse.rap.ui.workbench as a dependency and create the following class:

package org.eclipse.rap.demo.ui.tests;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.lifecycle.IEntryPoint;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TestApp implements IEntryPoint {

	public Display createUI() {
		Display d = new Display();
		final Shell s = new Shell(d, SWT.SHELL_TRIM);
		s.setLayout(new GridLayout());
		s.setText("App Title");
		final Button b1 = new Button(s, SWT.PUSH);
		b1.setText("Before");
		b1.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				MessageDialog.openInformation(s, "MessageBox",
						"Changing the button text now...", null);
				b1.setText("After");
			}
		});
		s.pack();
		s.open();
		return d;
	}

}

As you can see, this is a really tiny RAP example - but big enough to be worth to test it.

Preparing the tests

Now create a new java project and add the JUnit library. Additionally, you need to add the selenium-java-client-driver.jar to your project in order to use the Selenium Remote Control.

As we


Creating the test cases

Running the Selenium RC server

The Selenium RC server is a little server written in Java which cares about the interaction between your Junit tests and the browser instances. As it offers some webservices for us, we need to start it before running our tests.

Test it!

Back to the top