|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | CONST | FIELD | CONSTR | METHOD | DETAIL: CONST | FIELD | CONSTR | METHOD | ||||||||
public interface TestLogThis is the public interface for test log files. If used properly, this interface ensures that the contents of the results file conforms to applicable standards so that it can be read by other programs.
Use logLine to write a single
complete line of output.
Use log to write part of a line.
Test logs are block-structured; they consist of a number of nested blocks
that divide the log file into logical sections such as testcases. Most
of these blocks are maintained automatically by other testing classes,
but you can explicitly create your own blocks using
beginBlock
and endBlock.
Report simple errors (that are not exceptions) by calling
logError.
If you want to include additional information about an error,
you can create an error block by calling
beginError
and endError.
Log files support custom tab stops; tab characters are expanded to spaces
that pad to the next tab stop. Tab stops are normally every 4 columns;
you can set whatever tab stops you want by calling
setTabs.
Long lines are automatically wrapped. You can set the maximum line width
by calling setMaxWidth.
You can set the line break characters by calling
setLineBreakChars.
TestScript,
Testcase| Method Summary | |
TestLogBlock |
beginBlock(java.lang.String title)
Begins a new nested block in the log file. |
TestLogBlock |
beginError(java.lang.String str)
Writes an error message to the log file, increments the error count, and opens a block that will contain additional error information. |
TestLogBlock |
beginWarning(java.lang.String str)
Writes a warning message to the log file, increments the warning count, and opens a block that will contain additional warning information. |
void |
debug(java.lang.String str)
Logs a debugging statement as a separate line, prefixed with "# ". |
void |
endBlock(TestLogBlock block)
Ends the current block, which must be given. |
void |
endError(TestLogBlock errBlock)
Ends an error block that was begun by a call to beginError. |
void |
endWarning(TestLogBlock warningBlock)
Ends an warning block that was begun by a call to beginWarning. |
void |
log(java.lang.String str)
Writes a string to the log file, without any implicit line endings. |
void |
logDateTime()
Writes the current date & time to the log file in a standard format. |
void |
logDateTime(java.util.Date d)
Writes a date & time to the log file in the following standard format: |
void |
logError(java.lang.String str)
Writes an error message to the log file and increments the error count. |
void |
logException(java.lang.Throwable x)
Writes an exception message to the log file and increments the error count. |
void |
logFile(java.lang.String name,
java.lang.String descr)
Writes the name of an associated file. |
void |
logLine(java.lang.String str)
Writes a string to the log file as a separate line. |
void |
logWarning(java.lang.String str)
Writes a warning message to the log file and increments the warning count. |
void |
restoreBlock(TestLogBlock block)
Restores the block context. |
void |
setLineBreakChars(java.lang.String before,
java.lang.String after)
Sets line break characters for wrapping long lines for the current block. |
int |
setMaxWidth(int chars)
Sets the maximum physical line width in characters. |
void |
setTabs(int[] tabs)
Sets tab stops for the current block. |
void |
setTabs(int count,
int spacing)
Sets equal tab stops for the current block. |
| Method Detail |
public void log(java.lang.String str)
throws java.io.IOException
str
public void logLine(java.lang.String str)
throws java.io.IOException
str
public void logDateTime(java.util.Date d)
throws java.io.IOException
YYYY-MM-DD HH:MM:SS
Always use this method to write dates & times, so that they can be read from the log by post-processing programs.
d
public void logDateTime()
throws java.io.IOException
public void logFile(java.lang.String name,
java.lang.String descr)
throws java.io.IOException
namedescr
public void debug(java.lang.String str)
throws java.io.IOException
public void logError(java.lang.String str)
throws java.io.IOException
beginError and
endError instead of
logError.
str
public TestLogBlock beginError(java.lang.String str)
throws java.io.IOException
endError.
If you have no additional data to associate with this error, use
logError instead.
strendError.
public void endError(TestLogBlock errBlock)
throws java.io.IOException
beginError.
errBlockbeginError.
public void logWarning(java.lang.String str)
throws java.io.IOException
str
public TestLogBlock beginWarning(java.lang.String str)
throws java.io.IOException
endWarning.
If you have no additional data to associate with this warning, use
logWarning instead.
strendWarning.
public void endWarning(TestLogBlock warningBlock)
throws java.io.IOException
beginWarning.
warningBlockbeginWarning.
public void logException(java.lang.Throwable x)
throws java.io.IOException
Scripts should normally not need to log exceptions; exceptions should normally be left for the testing infrastructure to catch and report.
x
public TestLogBlock beginBlock(java.lang.String title)
throws java.io.IOException
endBlock.
the
public void endBlock(TestLogBlock block)
throws java.io.IOException
block
public void restoreBlock(TestLogBlock block)
throws java.io.IOException
TestLogBlock blk = log.beginBlock("some stuff");
try
{
// ... do some stuff ...
}
catch (whatever)
{
log.restoreBlock(blk);
// ... handle the exception ...
}
log.endBlock(blk);
If an exception is thrown inside the try block after
some other log block is begun (nested within the "some block" block),
but before that other log block has been ended, then without the
call to restoreBlock, the final call to
endBlock will fail an assertion because the block it
is trying to end is not the current block.
blockpublic void setTabs(int[] tabs)
tabs
public void setTabs(int count,
int spacing)
countspacingpublic int setMaxWidth(int chars)
public void setLineBreakChars(java.lang.String before,
java.lang.String after)
beforeafter| Revision History |
7/31/01 Ed Stauff - code review.
5/15/01 Ed Stauff - changes per 2nd API review.
4/6/01 Ed Stauff - made changes per API review.
3/22/01 Ed Stauff - initial API review by Satin team.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | CONST | FIELD | CONSTR | METHOD | DETAIL: CONST | FIELD | CONSTR | METHOD | ||||||||
TestLog.java (PRIVATE SOURCES)