Search in sources :

Example 1 with TestDescriptor

use of org.eclipse.core.tests.session.TestDescriptor in project eclipse.platform.runtime by eclipse.

the class MultipleRunsTest2 method suite.

public static Test suite() {
    PerformanceSessionTestSuite suite = new PerformanceSessionTestSuite(CoreTest.PI_HARNESS, 10);
    suite.addTest(new TestDescriptor(SampleSessionTest.class.getName(), "testApplicationStartup"));
    return suite;
}
Also used : PerformanceSessionTestSuite(org.eclipse.core.tests.session.PerformanceSessionTestSuite) TestDescriptor(org.eclipse.core.tests.session.TestDescriptor)

Example 2 with TestDescriptor

use of org.eclipse.core.tests.session.TestDescriptor in project eclipse.platform.runtime by eclipse.

the class MultipleRunsTest method testMultipleRuns.

public void testMultipleRuns() throws SetupManager.SetupException {
    // the test case to run multiple times
    TestDescriptor test = new TestDescriptor(SampleSessionTest.class.getName(), "testApplicationStartup");
    test.setApplicationId(SessionTestSuite.CORE_TEST_APPLICATION);
    test.setPluginId(CoreTest.PI_HARNESS);
    test.setTestRunner(new SessionTestRunner());
    // setup the command line to be passed to the multiple runs so it has the right system properties
    test.setSetup(SetupManager.getInstance().getDefaultSetup());
    test.getSetup().setSystemProperty("eclipse.perf.dbloc", System.getProperty("eclipse.perf.dbloc"));
    test.getSetup().setSystemProperty("eclipse.perf.config", System.getProperty("eclipse.perf.config"));
    // runs the test case several times - only to collect data, won't do any assertions
    TestResult result = new TestResult();
    for (int i = 0; i < 5; i++) {
        test.run(result);
        if (result.failureCount() > 0) {
            result.failures().nextElement().thrownException().printStackTrace();
            return;
        }
        if (result.errorCount() > 0) {
            result.errors().nextElement().thrownException().printStackTrace();
            return;
        }
    }
    // create a performance meter whose scenario id matches the one used in the test case run
    // our convention: scenario IDs are <test case class name> + '.' + <test case method name>
    PerformanceMeter meter = Performance.getDefault().createPerformanceMeter(test.getTestClass() + '.' + test.getTestMethod());
    // finally do the assertion
    Performance.getDefault().assertPerformanceInRelativeBand(meter, Dimension.ELAPSED_PROCESS, -50, 5);
}
Also used : SessionTestRunner(org.eclipse.core.tests.session.SessionTestRunner) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) TestResult(junit.framework.TestResult) TestDescriptor(org.eclipse.core.tests.session.TestDescriptor)

Aggregations

TestDescriptor (org.eclipse.core.tests.session.TestDescriptor)2 TestResult (junit.framework.TestResult)1 PerformanceSessionTestSuite (org.eclipse.core.tests.session.PerformanceSessionTestSuite)1 SessionTestRunner (org.eclipse.core.tests.session.SessionTestRunner)1 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)1