当前位置: 首页>>代码示例>>Java>>正文


Java TestListener类代码示例

本文整理汇总了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());
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:14,代码来源:OldTestClassAdaptingListenerTest.java

示例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);
}
 
开发者ID:apache,项目名称:ant,代码行数:8,代码来源:IgnoredTestResult.java

示例3: removeListener

import junit.framework.TestListener; //导入依赖的package包/类
@Override
public synchronized  void removeListener(TestListener listener) {
    if (listener instanceof IgnoredTestListener) {
        listeners.remove(listener);
    }
    super.removeListener(listener);
}
 
开发者ID:apache,项目名称:ant,代码行数:8,代码来源:IgnoredTestResult.java

示例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());
}
 
开发者ID:isandlaTech,项目名称:cohorte-utilities,代码行数:31,代码来源:CCpntDefaultTestExecuter.java

示例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();
	}
}
 
开发者ID:MagicHry,项目名称:EnhancedPUMA,代码行数:75,代码来源:MyUiAutomatorTestRunner.java

示例6: addTestListener

import junit.framework.TestListener; //导入依赖的package包/类
protected void addTestListener(TestListener listener) {
	if (!mTestListeners.contains(listener)) {
		mTestListeners.add(listener);
	}
}
 
开发者ID:MagicHry,项目名称:EnhancedPUMA,代码行数:6,代码来源:MyUiAutomatorTestRunner.java

示例7: removeTestListener

import junit.framework.TestListener; //导入依赖的package包/类
protected void removeTestListener(TestListener listener) {
	mTestListeners.remove(listener);
}
 
开发者ID:MagicHry,项目名称:EnhancedPUMA,代码行数:4,代码来源:MyUiAutomatorTestRunner.java

示例8: createAdaptingListener

import junit.framework.TestListener; //导入依赖的package包/类
public TestListener createAdaptingListener(final RunNotifier notifier) {
    return new OldTestClassAdaptingListener(notifier);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:4,代码来源:JUnit38ClassRunner.java

示例9: TestListenerWrapper

import junit.framework.TestListener; //导入依赖的package包/类
public TestListenerWrapper(TestListener listener) {
    super();
    wrapped = listener;
}
 
开发者ID:apache,项目名称:ant,代码行数:5,代码来源:TestListenerWrapper.java


注:本文中的junit.framework.TestListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。