Example usage for junit.framework TestResult runProtected

List of usage examples for junit.framework TestResult runProtected

Introduction

In this page you can find the example usage for junit.framework TestResult runProtected.

Prototype

public void runProtected(final Test test, Protectable p) 

Source Link

Document

Runs a TestCase.

Usage

From source file:org.eclipse.gemini.blueprint.test.AbstractOsgiTests.java

/**
 * {@inheritDoc}/*from ww w.j  av  a  2  s.  c  om*/
 * 
 * <p/> Replacement run method. Gets a hold of the TestRunner used for running this test so it can populate it with
 * the results retrieved from OSGi.
 */
public final void run(TestResult result) {

    // get a hold of the test result
    originalResult = result;

    result.startTest(osgiJUnitTest);
    result.runProtected(osgiJUnitTest, new Protectable() {

        public void protect() throws Throwable {
            AbstractOsgiTests.this.runBare();
        }
    });
    result.endTest(osgiJUnitTest);

    // super.run(result);
}

From source file:org.eclipse.gemini.blueprint.test.internal.support.OsgiJUnitService.java

/**
 * Run fixture setup, test from the given test case and fixture teardown.
 * // w ww  .ja  v  a2 s .  co  m
 * @param osgiTestExtensions
 * @param testName
 */
protected TestResult runTest(final OsgiJUnitTest osgiTestExtensions, String testName) {
    if (log.isDebugEnabled())
        log.debug("Running test [" + testName + "] on testCase " + osgiTestExtensions);
    final TestResult result = new TestResult();
    TestCase rawTest = osgiTestExtensions.getTestCase();

    rawTest.setName(testName);

    try {
        osgiTestExtensions.osgiSetUp();

        try {
            // use TestResult method to bypass the setUp/tearDown methods
            result.runProtected(rawTest, new Protectable() {

                public void protect() throws Throwable {
                    osgiTestExtensions.osgiRunTest();
                }

            });
        } finally {
            osgiTestExtensions.osgiTearDown();
        }

    }
    // exceptions thrown by osgiSetUp/osgiTearDown
    catch (Exception ex) {
        log.error("test exception threw exception ", ex);
        result.addError((Test) rawTest, ex);
    }
    return result;
}