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

RedDeerSuite

jbdevstudioqajenkins edited this page Jul 14, 2015 · 48 revisions

RedDeerSuite takes care of proper test initialization and configuration of tests (via annotations and configuration xml files)

Basic testsuite

For simple use of RedDeer JUnit component, just annotate your test class as @RedDeerSuite like so:

package org.jboss.reddeer.snippet.suite;

import org.jboss.reddeer.junit.runner.RedDeerSuite;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(RedDeerSuite.class)
public class Tests {

    @Test
    public void testCaseOne(){
        // here goes logic
    }

    @Test
    public void testCaseTwo(){
        // here goes logic
    }
}

source code

###Basic testsuite with multiple test classes With RedDeer you can create test suites with multiple classes the same way it is with JUnit4 (by using @SuiteClasses annotation)

package org.jboss.reddeer.snippet.suite;

import org.jboss.reddeer.junit.runner.RedDeerSuite;
import org.jboss.reddeer.snippet.test.Test1;
import org.jboss.reddeer.snippet.test.Test2;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(RedDeerSuite.class)
@SuiteClasses({
	Test1.class,
    Test2.class
})
public class TestsSuite {

}

source code

Extending RedDeerSuite

RedDeerSuite can be extended to provide pre and/or post actions (like cleanup workspace, closing startup popup shell, ...)

package org.jboss.reddeer.snippet.suite;

import org.jboss.reddeer.junit.runner.RedDeerSuite;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;

/**
 * Customized test suite.
 * Allows to modify test suite initialization and perform pre actions and/or post actions.
 */
public class MyTestSuite extends RedDeerSuite {
	
    /**
     * Test suite constructor.
     * Could be used for some pre and post construct actions.
     */
    public MyTestSuite(Class<?> clazz, RunnerBuilder builder)
            throws InitializationError {
        super(clazz, builder);
    }

    @Override
    public void run(RunNotifier notifier) {
        // put here some actions called before tests run 
        // e.g. close welcome screen        
        super.run(notifier);
        // put here some actions called after tests run
        // e.g. cleanup workspace
    }
}

source code

Clone this wiki locally