-
Notifications
You must be signed in to change notification settings - Fork 43
JUnit Extensions
JUnit test extensions are actions automatically invoked before or after every test run or test class. These actions usually include a typical setup or cleanup for your tests so you dont have to always use @Before, @BeforeClass or @After, @AfterClass.
Each JUnit extension can usually be disabled via setting respective system property.
If you want to use these extensions you have to install org.eclipse.reddeer.junit.extensions plugin (part of the org.jboss.reddeer.junit.extension.feature feature).
Following extensions are implemented:
-
CloseWelcomeScreenExt - Closes Welcome Screen if it is opened. Can be disabled by setting following system property to false. rd.closeWelcomeScreen=false
-
DisableAERI - Disables AERI error reporting
-
DoNotDownloadMavenIndexesExt - Disables Maven Repo Index downloading on startup. Can be disabled by setting following system property to false. rd.disableMavenIndex=false
-
MaximizeAndFoucsWorkbench - Maximizes and focuses workbench shell. Can be disabled by setting rd.maximizeWorkbench=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]
-
BeforesLogCollector - Collects eclipse log before @Before and @BeforeClass and writes its content to user.dir/target/reddeer-log
-
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
-
AftersLogCollector - Collects eclipse log after @After and @AfterClass and writes its content to user.dir/target/reddeer-log
To implement your own extensions you have to implement one of IBeforeTest or IAfterTest interface and register the extension via extension point org.eclipse.reddeer.junit.before.test or org.eclipse.reddeer.junit.after.test
public class CustomExtension implements IBeforeTest {
@Override
public long getPriority() {
//extension execution priority ie return Long.MAX_VALUE;
}
@Override
public void runBeforeTestClass(String config, TestClass testClass) {
//execute something before @BeforeClass
}
@Override
public void runBeforeTest(String config, Object target, FrameworkMethod method) {
//execute something before @Before
}
@Override
public boolean hasToRun() {
//decide if extension has to run
}
}
then we register our CustomExtension via extension point in plugin.xml
<plugin>
<extension
point="org.eclipse.reddeer.junit.before.test">
<client
class="FQN of CustomExtension">
</client>
</extension>
</plugin>