Search in sources :

Example 66 with TestCase

use of junit.framework.TestCase in project android_frameworks_base by crdroidandroid.

the class TestCaseUtilTest method testGetTestCaseNamesForTestCaseWithSuiteMethod.

public void testGetTestCaseNamesForTestCaseWithSuiteMethod() throws Exception {
    TestCase testCase = new OneTestTestCaseWithSuite();
    List<String> testCaseNames = TestCaseUtil.getTestCaseNames(testCase, false);
    assertEquals(1, testCaseNames.size());
    assertTrue(testCaseNames.get(0).endsWith("testOne"));
}
Also used : TestCase(junit.framework.TestCase)

Example 67 with TestCase

use of junit.framework.TestCase in project hackpad by dropbox.

the class ComplianceTest method createTest.

private static Test createTest(final File testDir, final String name) {
    return new TestCase(name) {

        @Override
        public int countTestCases() {
            return 1;
        }

        @Override
        public void runBare() throws Throwable {
            final Context cx = Context.enter();
            try {
                cx.setOptimizationLevel(-1);
                final Scriptable scope = cx.initStandardObjects();
                ScriptableObject.putProperty(scope, "print", new Print(scope));
                createRequire(testDir, cx, scope).requireMain(cx, "program");
            } finally {
                Context.exit();
            }
        }
    };
}
Also used : Context(org.mozilla.javascript.Context) TestCase(junit.framework.TestCase) Scriptable(org.mozilla.javascript.Scriptable)

Example 68 with TestCase

use of junit.framework.TestCase in project jna by java-native-access.

the class WebStartTest method runTestCaseTest.

private static Throwable runTestCaseTest(String testClass, String method, int port) throws Exception {
    TestCase test = (TestCase) Class.forName(testClass).newInstance();
    test.setName(method);
    TestResult result = new TestResult();
    test.run(result);
    if (result.failureCount() != 0) {
        Enumeration<TestFailure> e = result.failures();
        return e.nextElement().thrownException();
    } else if (result.errorCount() != 0) {
        Enumeration<TestFailure> e = result.errors();
        return e.nextElement().thrownException();
    }
    return null;
}
Also used : Enumeration(java.util.Enumeration) TestCase(junit.framework.TestCase) TestFailure(junit.framework.TestFailure) TestResult(junit.framework.TestResult)

Example 69 with TestCase

use of junit.framework.TestCase in project junit4 by junit-team.

the class TextFeedbackTest method testOneTest.

public void testOneTest() {
    String expected = expected(new String[] { ".", "Time: 0", "", "OK (1 test)", "" });
    TestSuite suite = new TestSuite();
    suite.addTest(new TestCase() {

        @Override
        public void runTest() {
        }
    });
    runner.doRun(suite);
    assertEquals(expected, output.toString());
}
Also used : TestSuite(junit.framework.TestSuite) TestCase(junit.framework.TestCase)

Example 70 with TestCase

use of junit.framework.TestCase in project junit4 by junit-team.

the class TextFeedbackTest method testFailure.

public void testFailure() {
    String expected = expected(new String[] { ".F", "Time: 0", "Failures here", "", "FAILURES!!!", "Tests run: 1,  Failures: 1,  Errors: 0", "" });
    ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {

        @Override
        public void printFailures(TestResult result) {
            getWriter().println("Failures here");
        }
    };
    runner.setPrinter(printer);
    TestSuite suite = new TestSuite();
    suite.addTest(new TestCase() {

        @Override
        public void runTest() {
            throw new AssertionFailedError();
        }
    });
    runner.doRun(suite);
    assertEquals(expected, output.toString());
}
Also used : PrintStream(java.io.PrintStream) TestSuite(junit.framework.TestSuite) ResultPrinter(junit.textui.ResultPrinter) TestCase(junit.framework.TestCase) TestResult(junit.framework.TestResult) AssertionFailedError(junit.framework.AssertionFailedError)

Aggregations

TestCase (junit.framework.TestCase)129 TestSuite (junit.framework.TestSuite)36 Test (junit.framework.Test)22 TestListener (junit.framework.TestListener)17 TestResult (junit.framework.TestResult)13 ArrayList (java.util.ArrayList)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 AssertionFailedError (junit.framework.AssertionFailedError)10 Constructor (java.lang.reflect.Constructor)8 Enumeration (java.util.Enumeration)6 Context (android.content.Context)5 PackageManager (android.content.pm.PackageManager)5 ResolveInfo (android.content.pm.ResolveInfo)5 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 Field (java.lang.reflect.Field)5 HashSet (java.util.HashSet)5