FileDocCategorySizeDatePackage
ResultPrinter.javaAPI DocAndroid 1.5 API3752Wed May 06 22:42:02 BST 2009junit.textui

ResultPrinter

public class ResultPrinter extends Object implements TestListener

Fields Summary
PrintStream
fWriter
int
fColumn
Constructors Summary
public ResultPrinter(PrintStream writer)

	
	   
		fWriter= writer;
	
Methods Summary
public voidaddError(junit.framework.Test test, java.lang.Throwable t)

see
junit.framework.TestListener#addError(Test, Throwable)

		getWriter().print("E");
	
public voidaddFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)

see
junit.framework.TestListener#addFailure(Test, AssertionFailedError)

		getWriter().print("F");
	
protected java.lang.StringelapsedTimeAsString(long runTime)
Returns the formatted string of the elapsed time. Duplicated from BaseTestRunner. Fix it.

            // The following line was altered for compatibility with
            // Android libraries.
	    return Double.toString((double)runTime/1000);
	
public voidendTest(junit.framework.Test test)

see
junit.framework.TestListener#endTest(Test)

	
public java.io.PrintStreamgetWriter()

		return fWriter;
	
synchronized voidprint(junit.framework.TestResult result, long runTime)

		printHeader(runTime);
	    printErrors(result);
	    printFailures(result);
	    printFooter(result);
	
public voidprintDefect(junit.framework.TestFailure booBoo, int count)

 // only public for testing purposes
		printDefectHeader(booBoo, count);
		printDefectTrace(booBoo);
	
protected voidprintDefectHeader(junit.framework.TestFailure booBoo, int count)

		// I feel like making this a println, then adding a line giving the throwable a chance to print something
		// before we get to the stack trace.
		getWriter().print(count + ") " + booBoo.failedTest());
	
protected voidprintDefectTrace(junit.framework.TestFailure booBoo)

		getWriter().print(BaseTestRunner.getFilteredTrace(booBoo.trace()));
	
protected voidprintDefects(java.util.Enumeration booBoos, int count, java.lang.String type)

		if (count == 0) return;
		if (count == 1)
			getWriter().println("There was " + count + " " + type + ":");
		else
			getWriter().println("There were " + count + " " + type + "s:");
		for (int i= 1; booBoos.hasMoreElements(); i++) {
			printDefect((TestFailure) booBoos.nextElement(), i);
		}
	
protected voidprintErrors(junit.framework.TestResult result)

		printDefects(result.errors(), result.errorCount(), "error");
	
protected voidprintFailures(junit.framework.TestResult result)

		printDefects(result.failures(), result.failureCount(), "failure");
	
protected voidprintFooter(junit.framework.TestResult result)

		if (result.wasSuccessful()) {
			getWriter().println();
			getWriter().print("OK");
			getWriter().println (" (" + result.runCount() + " test" + (result.runCount() == 1 ? "": "s") + ")");

		} else {
			getWriter().println();
			getWriter().println("FAILURES!!!");
			getWriter().println("Tests run: "+result.runCount()+ 
				         ",  Failures: "+result.failureCount()+
				         ",  Errors: "+result.errorCount());
		}
	    getWriter().println();
	
protected voidprintHeader(long runTime)

		getWriter().println();
		getWriter().println("Time: "+elapsedTimeAsString(runTime));
	
voidprintWaitPrompt()

		getWriter().println();
		getWriter().println("<RETURN> to continue");
	
public voidstartTest(junit.framework.Test test)

see
junit.framework.TestListener#startTest(Test)

		getWriter().print(".");
		if (fColumn++ >= 40) {
			getWriter().println();
			fColumn= 0;
		}