Skip to content

Getting Started

Ondrej Dockal edited this page Mar 6, 2019 · 41 revisions

Getting Started

Install RedDeer into Eclipse IDE

Copy-Paste this URL to Eclipse Help -> Install New Software...

http://download.eclipse.org/reddeer/releases/latest

Or latest nightly build

http://download.eclipse.org/reddeer/snapshots

Install at least RedDeer Runtime/API and RedDeer UI features.

Or you can also start with RedDeer Maven Archetype

Create a new RedDeer test project

To create a new RedDeer test project, navigate through workbench shell menu File -> New -> Other and select RedDeer - RedDeer Test Plug-in

When you fill out the required fields do not forget to check the Example test checkbox and click Finish.

Write and run your first test

This is the example test created by RedDeer wizard:

import static org.junit.Assert.*;

import org.eclipse.reddeer.eclipse.jdt.ui.wizards.JavaProjectWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewClassCreationWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne;
import org.eclipse.reddeer.eclipse.ui.views.markers.ProblemsView;
import org.eclipse.reddeer.eclipse.ui.views.markers.ProblemsView.ProblemType;
import org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.eclipse.reddeer.workbench.impl.editor.TextEditor;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 * RedDeer Test example generated by RedDeer Test Plug-in wizard
 */
@RunWith(RedDeerSuite.class)
public class RedDeerTest {

	@Test
	public void redDeerTestExample() {
		
		// Create Java Project
		JavaProjectWizard projectDlg = new JavaProjectWizard();
		projectDlg.open();
		NewJavaProjectWizardPageOne projectPage = new NewJavaProjectWizardPageOne(projectDlg);
		projectPage.setProjectName("testProject");
		projectDlg.finish();
		
		// Create Java class
		NewClassCreationWizard classDlg = new NewClassCreationWizard();
		classDlg.open();
		NewClassWizardPage classPage = new NewClassWizardPage(classDlg);
		classPage.setName("RedDeerDemo");
		classPage.setPackage("org.reddeer.demo");
		classDlg.finish();
		
		// Edit Java class
		TextEditor textEditor = new TextEditor("RedDeerDemo.java");
		textEditor.setText("Written by RedDeer");
		textEditor.save();
		
		// Check ProblemsView
		ProblemsView problemsView = new ProblemsView();
		problemsView.open();
		assertFalse(problemsView.getProblems(ProblemType.ERROR).isEmpty());
	}
}

Test execution

To run a test, open context menu Run As -> RedDeer Test on a project:

Further reading

Check out our documentation.

Clone this wiki locally