-
class
StreamingObserver
: TestObserver
-
Observer that generates a log by writing to a stream.
Logging test observers are typically used in terminal environments for
test log output or for generating reports as text files. This class is
the basis for a variety of log generators that create terminal and
file logs.
Public Members:
-
StreamingObserver ( ostream& log, bool enabled = true, bool permitCancel = false ) ;
-
Create a logging observer.
A reference to a stream is needed to which the log is written
as long as the stream isnīt changed. If enabled is true, the
observer will produce a log. If permitsCancel is true, the observer
allows to cancel a test session.
-
virtual ~StreamingObserver () ;
-
The destructor.
The log stream will be closed if the log was set by
specifying a filename.
-
virtual bool configureFrom (ArgVector& args) ;
-
Configure the log.
True is returned when the log is enabled.
Note that during configuration of an observer, exceptions
could be thrown, i.e. CannotOpenLog.
-
virtual Options<StreamingObserver>& options () ;
-
Get the defined set of options.
Only an empty set of options is returned.
StreamingObserver itself does not have any option handlers.
-
virtual bool enabled () const ;
-
Is the observer enabled?
Returns the enabled-status.
-
virtual void enabled (bool state) ;
-
Change the enabled-status.
If set to false before configureFrom is called, the observer
will not produce a log.
-
virtual bool permitsCancel () const ;
-
Check if the observer permits cancelling the execution of tests.
Return the value of permitCancel.
-
virtual void permitCancel (bool state) ;
-
Change the value of permitCancel.
If set to false, always a complete log will be written because
cancelling the test session is not possible anymore. Do this only
if absolutely necessary.
-
virtual void setLog (ostream& log) ;
-
Set another log output stream.
This function could be used to change the log output
after the observer was created. If the current log stream
was set by specifying a file name, the current log is closed
before the new one is set.
-
virtual void setLog (const string& filename) ;
-
Create a file log.
The observer will write its log into a file. If creating a file
with this name in the current environment is not possible,
the exception CannotOpenLog is thrown. The log file is closed
when another log is set or when the observer is destroyed.
-
ostream& log () ;
-
Returns a reference to the log output stream.
Convenience function.
The Scrunitizer C++ Unit Test Framework
by Bernd Linowski
[Scrunitizer]
[Overview]
[Cookbook]
[Download]
[Index]
[Linosphere]
Page generated: 1 Nov 2000
(C) by Bernd Linowski
scrunitizer@linosphere.de
|