Version 1

    This article is about how RedDeer framework simplifies workflow in writing eclipse tests that depend on application server.

    As a demostration an apache tomcat application server is used (because it is already integrated in RedDeer), but have in mind that there are several server requirements for JBoss AS already implemented in And you can even implement your own server requirements just by extending ServerRequirementsBase xsd and writing the supporting java classes. You can read more about RedDeer requirements here:


    The idea behind is simple. You just write a configuration xml file and annotate your test classes. All other is done by the RedDeer framework.





    Unpack Apache Tomcat 8 and Eclipse Luna. Start eclipse and install RedDeer framework from updatesite.


    Requirements Configuration


    The Red Deer JUnit component provides support for easy test run configuration by providing its own XML schema. To create a test run configuration you only need to create the XML file and point Red Deer either to that file or to the folder containing several XML configuration files by specifying the following property on the command line when you run your test:




    Prepare a configuration xml file for Apache Tomcat server requirement.

    <?xml version="1.0" encoding="UTF-8"?>
    <testrun xmlns="" xmlns:xsi=""
                  xmlns:db="" xmlns:server=""
              <!-- Example server configuration -->
              <server:server-requirement name="Tomcat8">
                        <server:familyApacheTomcat version="8.0" />



    Test Plugin


    We need to create a test plug-in first. Simply we can use New RedDeer Test Plug-in wizard. We will fill in plugin name, id (for example org.jboss.reddeer.tutorial.tomcat) and vendor (whatever) and click Finish.



    Use JUnit Test Wizard and create a Test Case. From main menu select File -> New ->Other… -> JUnit Test Case. Select a name e.g. ApacheTomcatTest and click finish.


    Apache Tomcat Test


    First add org.jboss.reddeer.requirements and org.jboss.reddeer.workbench dependency to the manifest in your test plugin.



    Then modify the (created in previous step):


    package org.jboss.reddeer.tutorial.tomcat;
    import static org.junit.Assert.*;
    import org.jboss.reddeer.eclipse.wst.server.ui.view.Server;
    import org.jboss.reddeer.eclipse.wst.server.ui.view.ServersView;
    import org.jboss.reddeer.eclipse.wst.server.ui.view.ServersViewEnums.ServerState;
    import org.jboss.reddeer.junit.requirement.inject.InjectRequirement;
    import org.jboss.reddeer.junit.runner.RedDeerSuite;
    import org.jboss.reddeer.requirements.server.ServerReqState;
    import org.jboss.reddeer.requirements.server.apache.tomcat.ServerRequirement;
    import org.jboss.reddeer.requirements.server.apache.tomcat.ServerRequirement.ApacheTomcatServer;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    public class ApacheTomcatTest {
      protected ServerRequirement requirement;
      public void isServerRunningTest(){
      ServersView sw = new ServersView();;
      Server s = sw.getServer(requirement.getServerNameLabelText(requirement.getConfig()));


    The example above shows how easy it is to use reddeer server requirements. First you need to annotate your test class with @ApacheTomcatServer annotation. In our case we request the server to be started before the test executes.

    In the class itself you'll need to inject the requirement. Then you can use it in your test methods.


    In this example we just test if the server has started. It is an UI test which opens the eclipse servers view, then finds the server (name can be read from the injected requirement) and reads the state of the server from UI.

    Server requirements are especially handy if you need to test eclipse tooling which has some application server capabilities. E.g adding runtimes, deployments etc.


    Run the Test


    Create new Run Configuration (Run As -> Run Configurations) - then double click on RedDeer Test. Select JUnit4 Test runner.



    Set the reddeer.config property in your run configuration. Point to a directory where is the requirements.xml file created in the first step of this tutorial.



    Click on Run. You will see another eclipse instance starting. The implemented test will automatically start the server and check if it's started.



    How to test against multiple server versions


    Often you need to test your tooling with various application server versions. Let's say tomcat 8, tomcat 7 and so fort.

    RedDeer is so clever that you don't need to change anything in your test suite.


    It's so simple that you just create multiple xml configuration files. In reddeer.config directory create tomcat8.xml, tomcat7.xml and so fort.

    RedDeer will automatically run the test against every configuration file that is found in the directory and fits the test annotation.