Search in sources :

Example 86 with TestResult

use of junit.framework.TestResult 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)

Example 87 with TestResult

use of junit.framework.TestResult in project tomee by apache.

the class TestRunner method main.

/**
 * main entry point.
 */
public static void main(final String[] args) {
    if (args.length == 0) {
        printHelp();
    } else {
        if (args[0].equals("--help")) {
            printHelp();
            return;
        } else if (args[0].equals("local")) {
            runLocalTests();
        } else if (args[0].equals("remote")) {
            runRemoteTests();
        } else if (args[0].equals("http")) {
            runRemoteHttpTests();
        } else if (args[0].equals("tomcat")) {
            runTomcatRemoteHttpTests();
        } else {
            printHelp();
            return;
        }
        try {
            final TestRunner aTestRunner = new TestRunner();
            final TestResult r = aTestRunner.start(new String[] { "org.apache.openejb.test.ClientTestSuite" });
            System.out.println("");
            System.out.println("_________________________________________________");
            System.out.println("CLIENT JNDI PROPERTIES");
            final Properties env = TestManager.getServer().getContextEnvironment();
            for (final Iterator iterator = env.entrySet().iterator(); iterator.hasNext(); ) {
                final Map.Entry entry = (Map.Entry) iterator.next();
                final String key = (String) entry.getKey();
                final Object value = entry.getValue();
                System.out.println(key + " = " + value);
            }
            System.out.println("_________________________________________________");
            if (!r.wasSuccessful())
                System.exit(FAILURE_EXIT);
            System.exit(SUCCESS_EXIT);
        } catch (final Exception e) {
            System.err.println(e.getMessage());
            System.exit(EXCEPTION_EXIT);
        }
    }
}
Also used : Iterator(java.util.Iterator) TestResult(junit.framework.TestResult) Properties(java.util.Properties) Map(java.util.Map)

Example 88 with TestResult

use of junit.framework.TestResult in project guava by google.

the class FeatureSpecificTestSuiteBuilderTest method testLifecycle.

public void testLifecycle() {
    boolean[] setUp = { false };
    Runnable setUpRunnable = new Runnable() {

        @Override
        public void run() {
            setUp[0] = true;
        }
    };
    boolean[] tearDown = { false };
    Runnable tearDownRunnable = new Runnable() {

        @Override
        public void run() {
            tearDown[0] = true;
        }
    };
    MyTestSuiteBuilder builder = new MyTestSuiteBuilder();
    Test test = builder.usingGenerator("yam").named("yam").withFeatures(CollectionFeature.NONE).withSetUp(setUpRunnable).withTearDown(tearDownRunnable).createTestSuite();
    TestResult result = new TestResult();
    test.run(result);
    assertTrue(testWasRun);
    assertTrue(setUp[0]);
    assertTrue(tearDown[0]);
}
Also used : Test(junit.framework.Test) TestResult(junit.framework.TestResult)

Example 89 with TestResult

use of junit.framework.TestResult in project mondrian by pentaho.

the class CacheHitTest method runTestSuiteInOrder.

/**
 * Loops <code>numIte</code> times, each time run all child test
 * suite in the <code>suite</code>
 *
 * @param suite the suite of test suites
 * @param numIter number of iterations
 * @throws Exception on error
 */
public void runTestSuiteInOrder(TestSuite suite, int numIter) throws Exception {
    final TestResult tres = new TestResult();
    final MondrianServer server = MondrianServer.forConnection(getTestContext().getConnection());
    for (int i = 0; i < numIter; i++) {
        TestSuite test = (TestSuite) suite.testAt(i % suite.testCount());
        for (int j = 0; j < test.testCount(); j++) {
            test.testAt(j).run(tres);
        }
    }
    report(server.getMonitor().getServer());
}
Also used : TestSuite(junit.framework.TestSuite) TestResult(junit.framework.TestResult)

Example 90 with TestResult

use of junit.framework.TestResult in project nutz by nutzam.

the class AdvancedTestAll method test.

public static TestResult test(List<Request> reqs, String name, Map<Request, Method> reqMap) {
    // TODO 根据order文件还原测试顺序
    try {
        FileWriter fw = new FileWriter("./test_order_" + name + ".txt");
        for (Request request : reqs) {
            fw.write(reqMap.get(request).toString());
            fw.write("\n");
        }
        fw.flush();
        fw.close();
    } catch (IOException e) {
    }
    final TestResult result = new TestResult();
    RunNotifier notifier = new RunNotifier();
    notifier.addListener(new RunListener() {

        public void testFailure(Failure failure) throws Exception {
            result.addError(asTest(failure.getDescription()), failure.getException());
        }

        public void testFinished(Description description) throws Exception {
            result.endTest(asTest(description));
        }

        public void testStarted(Description description) throws Exception {
            result.startTest(asTest(description));
        }

        public junit.framework.Test asTest(Description description) {
            return new junit.framework.Test() {

                public void run(TestResult result) {
                    throw Lang.noImplement();
                }

                public int countTestCases() {
                    return 1;
                }
            };
        }
    });
    for (Request request : reqs) {
        request.getRunner().run(notifier);
    }
    return result;
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Description(org.junit.runner.Description) FileWriter(java.io.FileWriter) Request(org.junit.runner.Request) TestResult(junit.framework.TestResult) IOException(java.io.IOException) IOException(java.io.IOException) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test) TestFailure(junit.framework.TestFailure) Failure(org.junit.runner.notification.Failure)

Aggregations

TestResult (junit.framework.TestResult)108 TestSuite (junit.framework.TestSuite)33 Test (junit.framework.Test)19 JUnit4TestAdapter (junit.framework.JUnit4TestAdapter)17 TestCase (junit.framework.TestCase)14 TestFailure (junit.framework.TestFailure)12 Test (org.junit.Test)10 TestListener (junit.framework.TestListener)9 ArrayList (java.util.ArrayList)8 PrintStream (java.io.PrintStream)7 RepeatedTest (junit.extensions.RepeatedTest)7 Enumeration (java.util.Enumeration)6 Bundle (android.os.Bundle)5 HandlerThread (android.os.HandlerThread)5 ShellUiAutomatorBridge (com.android.uiautomator.core.ShellUiAutomatorBridge)5 Tracer (com.android.uiautomator.core.Tracer)5 UiAutomationShellWrapper (com.android.uiautomator.core.UiAutomationShellWrapper)5 AssertionFailedError (junit.framework.AssertionFailedError)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4