Skip to content

JUnit test extensions

Marián Labuda edited this page Aug 19, 2016 · 18 revisions

API/Abstract

Implementation(s)

Usage

JUnit test extensions are actions automatically invoked before or after each and every test is run. They should replace using JUnit annotations @AfterClass, @After and @BeforeClass, @Before for actions invoked for every test so there is no need to copy these action to every test source code. Extension implement IExecutionPriority interface. Order of execution depends on extension priority. For sooner execution use higher value. RedDeer native extensions have their priority described in class ExtensionPriority.

JUnit extensions are implemented via IBeforeTest and IAfterTest extension points defined within org.jboss.reddeer.junit plugin.

IBeforeTest has 2 methods - runBeforeTestClass is similar to @BeforeClass (is invoked only once per test class, before requirements are fullfilled) and runBeforeTest is similar to @Before (invoked before every test method). Also, IAfterTest has 2 methods - runAfterTestClass (runs after requirements cleanup) and runAfterTest (runs after every test).

These extension points are implemented within org.jboss.reddeer.junit.extension plugin which is installed by org.jboss.reddeer.junit.extension.feature feature. This feature is mandatory and has to be installed in order to be able to use JUnit extensions defined in RedDeer.

Each JUnit Extension can be disabled via setting respective system property

CloseWelcomeScreenExt

Closes Welcome Screen if it is opened. It's enabled by default. Can be disabled by setting following system property to false.

rd.closeWelcomeScreen=false

DoNotDownloadMavenIndexesExt

Disables downloading maven repository indexes at Eclipse start-up prior test is run. It's enabled by default. Can be disabled by setting following system property to false.

rd.disableMavenIndex=false

SetOpenAssociatedPerspectiveExt

Sets Open Associated Perspective behavior. By default it disables opening of associated perspective when a new project is created. Desired behavior can be set by setting following system property to appropriate value.

rd.openAssociatedPerspective=[prompt|always|never]

CloseAllShellsExt

Closes all opened shells except the workbench shell when test is finished. If there is any shell closed by this extension, finished test will fail. This ensures there is no opened shell before run of a next test. Can be disabled by setting following system property to false.

rd.closeShells=false

Clone this wiki locally