Search in sources :

Example 71 with TestResult

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

the class FeatureSpecificTestSuiteBuilderTest method testLifecycle.

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

        @Override
        public void run() {
            setUp[0] = true;
        }
    };
    final 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 72 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)

Example 73 with TestResult

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

the class InstrumentationTestSuiteBuilderTest 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 74 with TestResult

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

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 75 with TestResult

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

the class InstrumentationTestSuiteBuilderTest 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)

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