001: /**************************************************************************/
002: /* NICE Testsuite */
003: /* A testsuite for the Nice programming language */
004: /* (c) Alex Greif 2002 */
005: /* */
006: /* This program is free software; you can redistribute it and/or modify */
007: /* it under the terms of the GNU General Public License as published by */
008: /* the Free Software Foundation; either version 2 of the License, or */
009: /* (at your option) any later version. */
010: /* */
011: /**************************************************************************/package nice.tools.testsuite.output;
012:
013: import java.io.*;
014: import java.util.*;
015:
016: import nice.tools.testsuite.*;
017:
018: /**
019: * Output logs the statements as text with indentations.
020: *
021: * @author Alex Greif <a href="mailto:alex.greif@web.de">alex.greif@web.de</a>
022: * @version $Id: TextOutput.java,v 1.5 2003/03/16 19:21:44 bonniot Exp $
023: */
024: public class TextOutput extends AbstractOutput {
025: /**
026: * TODO
027: *
028: */
029: private String _indentSign = " ";
030:
031: /**
032: * TODO
033: *
034: */
035: private int _indent = 0;
036:
037: /**
038: * TODO
039: *
040: * @param out TODO
041: */
042: public TextOutput(Writer out) {
043: super (out);
044: }
045:
046: /**
047: * TODO
048: *
049: */
050: private String indent() {
051: StringBuffer buf = new StringBuffer();
052: for (int i = 0; i < _indent; i++)
053: buf.append(_indentSign);
054:
055: return buf.toString();
056: }
057:
058: /**
059: * Called when the application starts up.
060: *
061: */
062: public void startApplication() {
063: logAndFlush("run test engine");
064: _indent++;
065: }
066:
067: /**
068: * Called when the application terminates.
069: *
070: */
071: public void endApplication() {
072: _indent--;
073: log("test engine finished");
074: log("");
075: log("number of testcases: " + (TestNice.getTotalTestCases()));
076: log(" successes : " + TestNice.getTestCasesSucceeded());
077: log(" regressions: " + TestNice.getTestCasesFailed());
078: log(" warnings : " + TestNice.getTestCasesWarning());
079: log(" known bugs : " + TestNice.getTestCasesKnownBug());
080: if (TestNice.getTestCasesFixed() > 0)
081: log(" FIXES :-)) : " + TestNice.getTestCasesFixed());
082:
083: logAndFlush("");
084: }
085:
086: /**
087: * Called when the testsuite starts to perform its testcases..
088: *
089: * @param testSuite TODO
090: */
091: public void startTestSuite(TestSuite testSuite) {
092: logAndFlush("testsuite: " + testSuite.getFile());
093: _indent++;
094: }
095:
096: /**
097: * Called when the testsuite finishes to perform its testcases..
098: *
099: */
100: public void endTestSuite() {
101: _indent--;
102: //log("finished");
103:
104: }
105:
106: /**
107: * Called when the testcase starts to perform.
108: *
109: * @param testCase TODO
110: */
111: public void startTestCase(TestCase testCase) {
112: mark();
113: log("testcase");
114: _indent++;
115: }
116:
117: /**
118: * Called when the testcase is performed.
119: *
120: * @param pass TODO
121: */
122: public void endTestCase(boolean pass) {
123: if (pass)
124: reset();
125: else
126: logAndFlush("fail");
127:
128: _indent--;
129: }
130:
131: /**
132: * TODO
133: *
134: */
135: protected String getIndent() {
136: return indent();
137: }
138:
139: }
|