-
Notifications
You must be signed in to change notification settings - Fork 44
Write and run your first minimal functional test
This section describes how to create and run your first Red Deer test from scratch.
For this illustration, we'll use Kepler and assume that you already have it installed.
###Step 2 - Install Red Deer into Eclipse In Eclipse, navigate to: Help->Install New Software:
Then, enter the Red Deer update site URL. For this illustration, we'll use the latest stable version (0.4.0):
http://download.jboss.org/jbosstools/updates/stable/kepler/core/reddeer/0.4.0/
See also Installation page for more details on installing Red Deer
After Red Deer is installed, you can create your first Red Deer project.
###Step 3 - Create a new Project of Type "Red Deer Test" To create the new Red Deer test project, select New->Project->Other->Red Deer Test:
After the empty project is created by the wizard, you can define a package and create a test class.
Here's the code for a minimal functional test. The test will verify that the eclipse configuration is not empty.
package org.jboss.reddeer.snippet.test;
import static org.junit.Assert.assertFalse;
import java.util.List;
import org.jboss.reddeer.common.logging.Logger;
import org.jboss.reddeer.swt.api.TreeItem;
import org.jboss.reddeer.swt.impl.button.PushButton;
import org.jboss.reddeer.swt.impl.menu.ShellMenu;
import org.jboss.reddeer.swt.impl.tree.DefaultTree;
import org.junit.Test;
public class SimpleTest {
private Logger logger = new Logger(SimpleTest.class);
@Test
public void TestIt() {
new ShellMenu("Help", "About Eclipse Platform").select();
new PushButton("Installation Details").click();
DefaultTree ConfigTree = new DefaultTree();
List<TreeItem> ConfigItems = ConfigTree.getAllItems();
assertFalse ("The list is empty!", ConfigItems.isEmpty());
for (TreeItem item : ConfigItems) {
logger.info("Found: " + item.getText());
}
}
}
After you save the test's source file, you can run the test.
To run the test, select the Run As->Red Deer Test option:
And - there's the green bar!
Congratulations! You've created and run your first Red Deer test!