本文整理汇总了Java中junit.framework.TestListener类的典型用法代码示例。如果您正苦于以下问题:Java TestListener类的具体用法?Java TestListener怎么用?Java TestListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestListener类属于junit.framework包,在下文中一共展示了TestListener类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFailureDelegatesToNotifier
import junit.framework.TestListener; //导入依赖的package包/类
@Test
public void addFailureDelegatesToNotifier() {
Result result = new Result();
RunListener listener = result.createListener();
RunNotifier notifier = new RunNotifier();
notifier.addFirstListener(listener);
TestCase testCase = new TestCase() {
};
TestListener adaptingListener = new JUnit38ClassRunner(testCase)
.createAdaptingListener(notifier);
adaptingListener.addFailure(testCase, new AssertionFailedError());
assertEquals(1, result.getFailureCount());
}
示例2: addListener
import junit.framework.TestListener; //导入依赖的package包/类
@Override
public synchronized void addListener(TestListener listener) {
if (listener instanceof IgnoredTestListener) {
listeners.add((IgnoredTestListener) listener);
}
super.addListener(listener);
}
示例3: removeListener
import junit.framework.TestListener; //导入依赖的package包/类
@Override
public synchronized void removeListener(TestListener listener) {
if (listener instanceof IgnoredTestListener) {
listeners.remove(listener);
}
super.removeListener(listener);
}
示例4: run
import junit.framework.TestListener; //导入依赖的package包/类
@Override
public void run() {
IBundleTest[] wTests = this.pBundleTests.clone();
TestResult aResult = new TestResult();
synchronized (pTestListeners) {
for (TestListener wListener : pTestListeners) {
aResult.addListener(wListener);
}
}
Arrays.sort(wTests, new Comparator<IBundleTest>() {
@Override
public int compare(final IBundleTest o1, final IBundleTest o2) {
return o1.getOrder() - o2.getOrder();
}
});
this.pLogger.logInfo(this, "run", "Aggrecation [%d] test(s).",
wTests.length);
TestSuite wSuite = new TestSuite("OSGi Bundles Test Aggregation");
for (IBundleTest wTest : wTests) {
this.pLogger.logInfo(this, "run", "Adding [%s] to test suite.",
wTests.toString());
wSuite.addTest(wTest);
}
this.pLogger.logInfo(this, "run", "Running test suite.");
wSuite.run(aResult);
this.pLogger.logInfo(this, "run", "Test successful? [%s].",
aResult.wasSuccessful());
}
示例5: start
import junit.framework.TestListener; //导入依赖的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();
}
}
示例6: addTestListener
import junit.framework.TestListener; //导入依赖的package包/类
protected void addTestListener(TestListener listener) {
if (!mTestListeners.contains(listener)) {
mTestListeners.add(listener);
}
}
示例7: removeTestListener
import junit.framework.TestListener; //导入依赖的package包/类
protected void removeTestListener(TestListener listener) {
mTestListeners.remove(listener);
}
示例8: createAdaptingListener
import junit.framework.TestListener; //导入依赖的package包/类
public TestListener createAdaptingListener(final RunNotifier notifier) {
return new OldTestClassAdaptingListener(notifier);
}
示例9: TestListenerWrapper
import junit.framework.TestListener; //导入依赖的package包/类
public TestListenerWrapper(TestListener listener) {
super();
wrapped = listener;
}