Search in sources :

Example 76 with TestResult

use of junit.framework.TestResult in project android_frameworks_base by DirtyUnicorns.

the class TestSuiteBuilderTest method runSuite.

private SuiteExecutionRecorder runSuite(TestSuiteBuilder builder) {
    TestSuite suite = builder.build();
    SuiteExecutionRecorder recorder = new SuiteExecutionRecorder();
    TestResult result = new TestResult();
    result.addListener(recorder);
    suite.run(result);
    return recorder;
}
Also used : TestSuite(junit.framework.TestSuite) TestResult(junit.framework.TestResult)

Example 77 with TestResult

use of junit.framework.TestResult in project android_frameworks_base by DirtyUnicorns.

the class UnitTestSuiteBuilderTest method runSuite.

private SuiteExecutionRecorder runSuite(TestSuiteBuilder builder) {
    TestSuite suite = builder.build();
    SuiteExecutionRecorder recorder = new SuiteExecutionRecorder();
    TestResult result = new TestResult();
    result.addListener(recorder);
    suite.run(result);
    return recorder;
}
Also used : TestSuite(junit.framework.TestSuite) TestResult(junit.framework.TestResult)

Example 78 with TestResult

use of junit.framework.TestResult in project ACS by ACS-Community.

the class NoDotJUnitRunner method main.

/**
	 * Copied from base class TestRunner, except that a NoDotJUnitRunner gets created.
	 */
public static void main(String[] args) {
    NoDotJUnitRunner aTestRunner = new NoDotJUnitRunner();
    try {
        TestResult r = aTestRunner.start(args);
        if (!r.wasSuccessful())
            System.exit(FAILURE_EXIT);
        System.exit(SUCCESS_EXIT);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        System.exit(EXCEPTION_EXIT);
    }
}
Also used : TestResult(junit.framework.TestResult)

Example 79 with TestResult

use of junit.framework.TestResult in project android_frameworks_base by ResurrectionRemix.

the class UiAutomatorTestRunner method start.

/**
     * Called after all test classes are in place, ready to test
     */
protected void start() {
    TestCaseCollector collector = getTestCaseCollector(this.getClass().getClassLoader());
    try {
        collector.addTestClasses(mTestClasses);
    } catch (ClassNotFoundException e) {
        // will be caught by uncaught handler
        throw new RuntimeException(e.getMessage(), e);
    }
    if (mDebug) {
        Debug.waitForDebugger();
    }
    mHandlerThread = new HandlerThread(HANDLER_THREAD_NAME);
    mHandlerThread.setDaemon(true);
    mHandlerThread.start();
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    long startTime = SystemClock.uptimeMillis();
    TestResult testRunResult = new TestResult();
    ResultReporter resultPrinter;
    String outputFormat = mParams.getString("outputFormat");
    List<TestCase> testCases = collector.getTestCases();
    Bundle testRunOutput = new Bundle();
    if ("simple".equals(outputFormat)) {
        resultPrinter = new SimpleResultPrinter(System.out, true);
    } else {
        resultPrinter = new WatcherResultPrinter(testCases.size());
    }
    try {
        automationWrapper.setRunAsMonkey(mMonkey);
        mUiDevice = UiDevice.getInstance();
        mUiDevice.initialize(new ShellUiAutomatorBridge(automationWrapper.getUiAutomation()));
        String traceType = mParams.getString("traceOutputMode");
        if (traceType != null) {
            Tracer.Mode mode = Tracer.Mode.valueOf(Tracer.Mode.class, traceType);
            if (mode == Tracer.Mode.FILE || mode == Tracer.Mode.ALL) {
                String filename = mParams.getString("traceLogFilename");
                if (filename == null) {
                    throw new RuntimeException("Name of log file not specified. " + "Please specify it using traceLogFilename parameter");
                }
                Tracer.getInstance().setOutputFilename(filename);
            }
            Tracer.getInstance().setOutputMode(mode);
        }
        // add test listeners
        testRunResult.addListener(resultPrinter);
        // add all custom listeners
        for (TestListener listener : mTestListeners) {
            testRunResult.addListener(listener);
        }
        // run tests for realz!
        for (TestCase testCase : testCases) {
            prepareTestCase(testCase);
            testCase.run(testRunResult);
        }
    } catch (Throwable t) {
        // catch all exceptions so a more verbose error message can be outputted
        resultPrinter.printUnexpectedError(t);
        testRunOutput.putString("shortMsg", t.getMessage());
    } finally {
        long runTime = SystemClock.uptimeMillis() - startTime;
        resultPrinter.print(testRunResult, runTime, testRunOutput);
        automationWrapper.disconnect();
        automationWrapper.setRunAsMonkey(false);
        mHandlerThread.quit();
    }
}
Also used : Bundle(android.os.Bundle) Tracer(com.android.uiautomator.core.Tracer) TestResult(junit.framework.TestResult) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper) HandlerThread(android.os.HandlerThread) TestCase(junit.framework.TestCase) ShellUiAutomatorBridge(com.android.uiautomator.core.ShellUiAutomatorBridge) TestListener(junit.framework.TestListener)

Example 80 with TestResult

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

the class SimpleTestRunner method runNoReport.

public static TestResult runNoReport(Test ts) {
    TestResult result = new TestResult();
    //result.addListener(new SilentListener()) ;
    result.addListener(new Listener());
    ts.run(result);
    return result;
}
Also used : TestListener(junit.framework.TestListener) TestResult(junit.framework.TestResult)

Aggregations

TestResult (junit.framework.TestResult)80 TestSuite (junit.framework.TestSuite)25 JUnit4TestAdapter (junit.framework.JUnit4TestAdapter)15 TestCase (junit.framework.TestCase)13 Test (junit.framework.Test)11 TestFailure (junit.framework.TestFailure)8 RepeatedTest (junit.extensions.RepeatedTest)7 TestListener (junit.framework.TestListener)7 Test (org.junit.Test)7 PrintStream (java.io.PrintStream)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 ResultPrinter (junit.textui.ResultPrinter)4 Enumeration (java.util.Enumeration)3 TestSetup (junit.extensions.TestSetup)3 AssertionFailedError (junit.framework.AssertionFailedError)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2