junit.framework.TestListener Java Examples

The following examples show how to use junit.framework.TestListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DelegatingTestResult.java    From android-test with Apache License 2.0 4 votes vote down vote up
@Override
public void addListener(TestListener listener) {
  wrappedResult.addListener(listener);
}
 
Example #2
Source File: DelegatingTestResult.java    From android-test with Apache License 2.0 4 votes vote down vote up
@Override
public void removeListener(TestListener listener) {
  wrappedResult.removeListener(listener);
}
 
Example #3
Source File: JUnit38ClassRunner.java    From android-test with Apache License 2.0 4 votes vote down vote up
public TestListener createAdaptingListener(final RunNotifier notifier) {
  return new OldTestClassAdaptingListener(notifier);
}
 
Example #4
Source File: MyUiAutomatorTestRunner.java    From PUMA with Apache License 2.0 4 votes vote down vote up
/**
 * 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();
	}
}
 
Example #5
Source File: MyUiAutomatorTestRunner.java    From PUMA with Apache License 2.0 4 votes vote down vote up
protected void addTestListener(TestListener listener) {
	if (!mTestListeners.contains(listener)) {
		mTestListeners.add(listener);
	}
}
 
Example #6
Source File: MyUiAutomatorTestRunner.java    From PUMA with Apache License 2.0 4 votes vote down vote up
protected void removeTestListener(TestListener listener) {
	mTestListeners.remove(listener);
}