Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Write and run your first minimal functional test

Marián Labuda edited this page Oct 22, 2015 · 59 revisions

###Step 1 - Create a new project of type "Red Deer Test" To create a new Red Deer test project, select New -> Project -> Other -> Red Deer Test:

Once an empty project is created by the wizard, you can define a package and create a test class.

Step 2 - Write your first test

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());
        }
    }
}

source code

After you save your source file, you can run this test.

Step 3 - Test execution

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!

Clone this wiki locally