本文整理汇总了Java中junit.framework.TestResult.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java TestResult.addListener方法的具体用法?Java TestResult.addListener怎么用?Java TestResult.addListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类junit.framework.TestResult
的用法示例。
在下文中一共展示了TestResult.addListener方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doRun
import junit.framework.TestResult; //导入方法依赖的package包/类
public TestResult doRun(Test suite, boolean wait) throws Exception {
StatsStore.open(jdbcDriver, connectionURL);
TestResult result = new TestResult();
result.addListener(fPrinter);
result.addListener(fPerfStatCollector);
long startTime= System.currentTimeMillis();
StatsStore.now = startTime;
suite.run(result);
long endTime= System.currentTimeMillis();
long runTime= endTime-startTime;
fPrinter.print(result, runTime);
fPerfStatCollector.digest();
StatsStore.close();
pause(wait);
return result;
}
示例2: runTestSuite
import junit.framework.TestResult; //导入方法依赖的package包/类
void runTestSuite( String testClassName ) {
Test suite = getTest( testClassName );
if (suite != null) {
TestResult testResult = new TestResult();
testResult.addListener( this );
long startTime= System.currentTimeMillis();
suite.run( testResult );
long endTime= System.currentTimeMillis();
_formatter.displayResults( _writer, testClassName, elapsedTimeAsString( endTime-startTime ), testResult );
}
}
示例3: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(TestResult result) {
result.addListener(listener);
dumpSystemInfo();
super.run(result);
listener.dumpResults(result);
// add dummy test to dump threads in case shutdown hangs
listener.startTest(new ShutdownWatchdog());
}
示例4: setUp
import junit.framework.TestResult; //导入方法依赖的package包/类
protected void setUp() {
fResult= new TestResult();
fResult.addListener(this);
fStartCount= 0;
fEndCount= 0;
fFailureCount= 0;
}
示例5: run
import junit.framework.TestResult; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void run(TestResult result) {
final Iterator<TestChunk> iterator = getChunkIterator();
for (PowerMockJUnit3RunnerDelegate delegate : delegates) {
TestChunk next = iterator.next();
final PowerMockJUnit3TestListener listener = new PowerMockJUnit3TestListener(next.getClassLoader());
result.addListener(listener);
// Initialize mock policies for each test
new MockPolicyInitializerImpl(delegate.getTestClass()).initialize(this.getClass().getClassLoader());
delegate.run(result);
result.removeListener(listener);
}
}
示例6: runTest
import junit.framework.TestResult; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void runTest(Test test, TestResult result) {
final Iterator<TestChunk> iterator = getChunkIterator();
for (PowerMockJUnit3RunnerDelegate delegate : delegates) {
TestChunk next = iterator.next();
final PowerMockJUnit3TestListener listener = new PowerMockJUnit3TestListener(next.getClassLoader());
result.addListener(listener);
delegate.runTest(test, result);
result.removeListener(listener);
}
}
示例7: doRun
import junit.framework.TestResult; //导入方法依赖的package包/类
public TestResult doRun(Test suite, boolean wait) {
TestResult result = createTestResult();
result.addListener(fPrinter);
long startTime = System.currentTimeMillis();
suite.run(result);
long endTime = System.currentTimeMillis();
long runTime = endTime - startTime;
fPrinter.print(result, runTime);
pause(wait);
return result;
}
示例8: setUp
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
protected void setUp() {
fResult = new TestResult();
fResult.addListener(this);
fStartCount = 0;
fEndCount = 0;
fFailureCount = 0;
fErrorCount = 0;
}
示例9: generatedErrorTestsMatchUp
import junit.framework.TestResult; //导入方法依赖的package包/类
@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());
}
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:11,代码来源:InitializationErrorForwardCompatibilityTest.java
示例10: doRun
import junit.framework.TestResult; //导入方法依赖的package包/类
/**
* Execute the test suite, specifiying our VerboseResultPrinter wrapper
* instead of TestRunner's use of the ordinary ResultPrinter.
*/
/*
* super.doRun() blabs out output about how long execution takes, which we
* don't particularly care about, and we need to override the TestListener
* (ie, ResultPrinter) used to output results - the whole point of the
* exercise.
*/
public TestResult doRun(Test suite) {
TestResult result = new TestResult();
result.addListener(new VerboseResultPrinter(true));
suite.run(result);
return result;
}
示例11: start
import junit.framework.TestResult; //导入方法依赖的package包/类
/**
* Called after all test classes are in place, ready to test
*/
protected void start() {
TestCaseCollector collector = getTestCaseCollector(this.getClass().getClassLoader());
try {
collector.addTestClasses(mTestClasses);
} catch (ClassNotFoundException e) {
// will be caught by uncaught handler
throw new RuntimeException(e.getMessage(), e);
}
if (mDebug) {
Debug.waitForDebugger();
}
mHandlerThread = new HandlerThread(HANDLER_THREAD_NAME);
mHandlerThread.setDaemon(true);
mHandlerThread.start();
UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
automationWrapper.connect();
long startTime = SystemClock.uptimeMillis();
TestResult testRunResult = new TestResult();
ResultReporter resultPrinter;
String outputFormat = mParams.getString("outputFormat");
List<TestCase> testCases = collector.getTestCases();
Bundle testRunOutput = new Bundle();
if ("simple".equals(outputFormat)) {
resultPrinter = new SimpleResultPrinter(System.out, true);
} else {
resultPrinter = new WatcherResultPrinter(testCases.size());
}
try {
automationWrapper.setRunAsMonkey(mMonkey);
mUiDevice = MyUiDevice.getInstance();
UiAutomation uiAutomation = automationWrapper.getUiAutomation();
mUiDevice.initialize(new ShellUiAutomatorBridge(uiAutomation));
mUiDevice.setUiAutomation(uiAutomation);
String traceType = mParams.getString("traceOutputMode");
if (traceType != null) {
Tracer.Mode mode = Tracer.Mode.valueOf(Tracer.Mode.class, traceType);
if (mode == Tracer.Mode.FILE || mode == Tracer.Mode.ALL) {
String filename = mParams.getString("traceLogFilename");
if (filename == null) {
throw new RuntimeException("Name of log file not specified. " + "Please specify it using traceLogFilename parameter");
}
Tracer.getInstance().setOutputFilename(filename);
}
Tracer.getInstance().setOutputMode(mode);
}
// add test listeners
testRunResult.addListener(resultPrinter);
// add all custom listeners
for (TestListener listener : mTestListeners) {
testRunResult.addListener(listener);
}
// run tests for realz!
for (TestCase testCase : testCases) {
prepareTestCase(testCase);
testCase.run(testRunResult);
}
} catch (Throwable t) {
// catch all exceptions so a more verbose error message can be outputted
resultPrinter.printUnexpectedError(t);
} finally {
long runTime = SystemClock.uptimeMillis() - startTime;
resultPrinter.print(testRunResult, runTime, testRunOutput);
automationWrapper.disconnect();
automationWrapper.setRunAsMonkey(false);
mHandlerThread.quit();
}
}
示例12: run
import junit.framework.TestResult; //导入方法依赖的package包/类
@Override
public void run(RunNotifier notifier) {
TestResult result = new TestResult();
result.addListener(createAdaptingListener(notifier));
getTest().run(result);
}