This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Write and run your first minimal functional test
Marián Labuda edited this page Mar 16, 2016
·
59 revisions
###Step 1 - Create a new RedDeer test project To create a new Red Deer test project, navigate through shell menu File -> New -> Other and select RedDeer - RedDeer Test Plug-in
Once an 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. This test verifies whether Eclipse configuration is empty or not.
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 your source file, you can run this test.
To run a test, open context menu Run As -> Red Deer Test on a project:
And that's all - there is green bar!
Congratulations! You've created and run your first Red Deer test!