use of junit.framework.TestListener in project junit4 by junit-team.
the class ForwardCompatibilityTest method testNotifyResult.
public void testNotifyResult() {
JUnit4TestAdapter adapter = new JUnit4TestAdapter(ErrorTest.class);
TestResult result = new TestResult();
final StringBuffer log = new StringBuffer();
result.addListener(new TestListener() {
public void startTest(junit.framework.Test test) {
log.append(" start ").append(test);
}
public void endTest(junit.framework.Test test) {
log.append(" end ").append(test);
}
public void addFailure(junit.framework.Test test, AssertionFailedError t) {
log.append(" failure ").append(test);
}
public void addError(junit.framework.Test test, Throwable e) {
log.append(" error " + test);
}
});
adapter.run(result);
String testName = String.format("error(%s)", ErrorTest.class.getName());
assertEquals(String.format(" start %s error %s end %s", testName, testName, testName), log.toString());
}
use of junit.framework.TestListener in project openj9 by eclipse.
the class TestDefenderSupersends method main.
/**
* @param args
*/
public static void main(String[] args) {
Class<?> testClass = AsmUtils.getDefenderSupersendTestcase();
Test suite = new TestSuite(testClass);
TestResult result = new TestResult();
result.addListener(new TestListener() {
public void addError(Test test, Throwable t) {
t.printStackTrace(System.err);
}
public void addFailure(Test test, AssertionFailedError t) {
t.printStackTrace(System.err);
}
public void endTest(Test test) {
System.out.println("Finished " + test);
}
public void startTest(Test test) {
System.out.println("Starting " + test);
}
});
suite.run(result);
System.out.println("================Test Result ==================");
System.out.println("Failures: " + result.failureCount() + " out of " + result.runCount() + " test cases.");
System.out.println("Errors: " + result.errorCount() + " out of " + result.runCount() + " test cases.");
// return value
}
use of junit.framework.TestListener in project openj9 by eclipse.
the class AutoRun method runTest.
/**
* This method is responsible for running the test suite in Native Debugger based DDR testing
* @param ctx - The context object
* @param out - The PrintStream object to be used to output logs
* @param testCaseList - Comma separated list of test suite classes to run
*/
public static void runTest(Context ctx, PrintStream out, String testCaseList) {
// initiate DDRInteractive instance
SetupConfig.init(ctx, out);
log.info("Executing test cases : " + testCaseList);
// Get the overall list of tests to ignore for native DDR tests as found in ddrext_excludes.xml
String excludeList = getExcludesFor(Constants.TESTDOMAIN_NATIVE);
Test suite = getTestSuite(testCaseList, excludeList);
// Based on the excludes defined in ddrext_excludes.xml, construct the list of tests to ignore from the full list of tests in
// the current test suite.
getExcludesForCurrentSuites(suite, excludeList);
int numberOfExcludesForCurrentSuite = 0;
if (excludesForCurrentSuite != null) {
if (excludesForCurrentSuite.contains(",") == false) {
numberOfExcludesForCurrentSuite = 1;
} else {
numberOfExcludesForCurrentSuite = excludesForCurrentSuite.split(",").length;
}
}
log.info("Running " + (suite.countTestCases() - numberOfExcludesForCurrentSuite) + " tests from ddrjunit plugin");
TestResult result = new TestResult();
result.addListener(new TestListener() {
public void addError(Test test, Throwable t) {
t.printStackTrace(System.err);
}
public void addFailure(Test test, AssertionFailedError t) {
t.printStackTrace(System.err);
}
public void endTest(Test test) {
log.info("Finished " + test + Constants.NL);
}
public void startTest(Test test) {
log.info("Starting " + test);
}
});
suite.run(result);
errCount = errCount + result.errorCount();
failCount = failCount + result.failureCount();
log.info("================Test Result==================");
log.info("Errors: " + result.errorCount() + " out of " + (suite.countTestCases() - numberOfExcludesForCurrentSuite) + " test cases.");
log.info("Failures: " + result.failureCount() + " out of " + (suite.countTestCases() - numberOfExcludesForCurrentSuite) + " test cases.");
if (numberOfExcludesForCurrentSuite != 0) {
log.info("Total tests excluded = " + numberOfExcludesForCurrentSuite + " [" + excludesForCurrentSuite + "]");
}
// After run test on the core file, reset DDRInteractive,outputString
// and ddrResultCache to null
SetupConfig.reset();
DDRExtTesterBase.resetList();
// print out success/failure info
log.info("Total Error/Failures: " + (errCount + failCount));
if ((errCount + failCount) > 0) {
System.exit(-2);
} else {
System.exit(0);
}
}
Aggregations