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);
}
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());
}
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());
}
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());
}
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)");
}
}
}
}
Aggregations