Search in sources :

Example 66 with TestResult

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

the class ForwardCompatibilityTest method testCompatibility.

public void testCompatibility() {
    fLog = "";
    TestResult result = new TestResult();
    junit.framework.Test adapter = new JUnit4TestAdapter(NewTest.class);
    adapter.run(result);
    assertEquals("before test after ", fLog);
}
Also used : TestResult(junit.framework.TestResult) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter)

Example 67 with TestResult

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

the class InitializationErrorForwardCompatibilityTest method generatedErrorTestsMatchUp.

@Test
public void generatedErrorTestsMatchUp() {
    junit.framework.Test shouldFail = fAdapter.getTests().get(0);
    TestResult result = new TestResult();
    ErrorRememberingListener listener = new ErrorRememberingListener();
    result.addListener(listener);
    fAdapter.run(result);
    assertNotNull(listener.getError());
    assertTrue(shouldFail == listener.getError());
}
Also used : TestResult(junit.framework.TestResult) Test(org.junit.Test)

Example 68 with TestResult

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

the class InitializationErrorForwardCompatibilityTest method initializationErrorsAreThrownAtRuntime.

@Test
public void initializationErrorsAreThrownAtRuntime() {
    TestResult result = new TestResult();
    fAdapter.run(result);
    assertEquals(1, result.errorCount());
    assertEquals(CantInitialize.UNIQUE_ERROR_MESSAGE, result.errors().nextElement().exceptionMessage());
}
Also used : TestResult(junit.framework.TestResult) Test(org.junit.Test)

Example 69 with TestResult

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

the class TestMethodTest method compatibility.

@Test
public void compatibility() {
    TestResult result = new TestResult();
    new JUnit4TestAdapter(IgnoredTest.class).run(result);
    assertEquals(1, result.runCount());
}
Also used : TestResult(junit.framework.TestResult) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter) Test(org.junit.Test)

Example 70 with TestResult

use of junit.framework.TestResult in project groovy-core by groovy.

the class SecurityTestSupport method executeTest.

protected void executeTest(Class test, Permission missingPermission) {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(test);
    TestResult result = new TestResult();
    suite.run(result);
    if (result.wasSuccessful()) {
        if (missingPermission == null) {
            return;
        } else {
            fail("Security test expected an AccessControlException on " + missingPermission + ", but did not receive one");
        }
    } else {
        if (missingPermission == null) {
            new SecurityTestResultPrinter(System.out).print(result);
            fail("Security test was expected to run successfully, but failed (results on System.out)");
        } else {
            //There may be more than 1 failure:  iterate to ensure that they all match the missingPermission.
            boolean otherFailure = false;
            for (Enumeration e = result.errors(); e.hasMoreElements(); ) {
                TestFailure failure = (TestFailure) e.nextElement();
                if (failure.thrownException() instanceof AccessControlException) {
                    AccessControlException ace = (AccessControlException) failure.thrownException();
                    if (missingPermission.implies(ace.getPermission())) {
                        continue;
                    }
                }
                otherFailure = true;
                break;
            }
            if (otherFailure) {
                new SecurityTestResultPrinter(System.out).print(result);
                fail("Security test expected an AccessControlException on " + missingPermission + ", but failed for other reasons (results on System.out)");
            }
        }
    }
}
Also used : Enumeration(java.util.Enumeration) TestSuite(junit.framework.TestSuite) TestFailure(junit.framework.TestFailure) 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