Contains implementation of JavaTESK Tracer -- a component used to trace test execution.

Each thread of a running test has an associated tracer object (of type {@link jatva.tracer.Tracer Tracer}). To get tracer object associated with a given thread one can use method {@link jatva.tracer.Tracer#getTracerObject(Thread) getTracerObject(Thread)}. To get tracer object associated with the current thread one can use method {@link jatva.tracer.Tracer#getTracerObject() getTracerObject()}.

Each thread uses the associated tracer object to send messages to trace. Configuration of a tracer object defines where the trace messages sent by this object will be stored and in what format. Trace detail level defines what messages should appear in result trace and what ones should be ignored. Configuration and trace detail level can be set separately for each tracer object.

There is so called default tracer object that can be accessed using method {@link jatva.tracer.Tracer#getDefault() getDefault()}. Configuration and trace detail level of this default tracer object defines properties of tracer object that are not configured explicitly.

Creation of a tracer object associated with a thread is performed automatically when somebody requests such a tracer object. At the moment of creation new tracer object copies properties of the default tracer object and all following changes in the default tracer object do not affect properties of the created tracer object associated with the specific thread.

JavaTESK Tracer has pluggable architecture. There are three kinds of plugins -- {@link jatva.tracer.TraceConstrainer TraceConstrainer} defines guarding strategy, {@link jatva.tracer.TraceFormatter TraceFormatter} defines formatting strategy, and {@link jatva.tracer.TraceWriter TraceWriter} defines trace destination strategy. JavaTESK Tracer contains implementation of trace destination strategies for most widely used cases -- console, file, network monitor, arbitrary {@link java.io.Writer}.

,

The full set of object (non-static) methods of Tracer class can be separated to three subsets -- methods for configuring tracer object, methods for sending messages to trace, and methods for managing trace detail level.

Configuring tracer object

To configure tracer object user should usually define trace destination strategy (rarely it is needed to define formatting or guarding strategy too).

There is two ways to configure JavaTESK Tracer via API -- universal one and handy one. Universal way is intended to set arbitrary strategy plugins and is used by test launcher primarily. User may use it for example to specify its own trace destination strategy.

More preferrable way to configure tracer object manually is use of special methods that allow to select one of trace destination and formatting strategies included in JavaTESK Tracer implementation (setTraceTo... method family is intended to select trace destination strategy, setFormatAs... method family is intended to select formatting strategy).

Configuration of tracer object associated with a thread should be completed before sending any message from this thread. After the moment a message sent to trace all configuration methods will have no effect and will show a warning message on console. So it is recommended to configure the tracer object before starting the thread -- either in its constructor or in another thread that starts the thread under consideration.

Creation of a tracer object associated with a thread is performed automatically when somebody requests such a tracer object. At the moment of creation new tracer object copies configuration of the default tracer object. So it is recommended to configure the default tracer object before starting threads that should use this default configuration.

Sending messages to trace

Most methods for sending messages to trace are designed for use in generated code of test system (trace_... method family). To stress this fact all these methods have names that do not conform standard Java naming convention. The only three methods that are exceptions to the rule: startTrace(), endTrace(), and traceUserInfo(String). Morover, methods startTrace() and endTrace() should be used only in test that do not conform to JavaTESK technology. Usually user uses only traceUserInfo(String) method.

Managing trace detail level

Methods for managing trace detail level (setTrace...(boolean) method family) allow to switch on and off one or another group of messages, including subgroups or not. The full set of message groups is listed below (group names are emphasized in italic):

scenario_start
scenario_end
exception
internal_error
scenarioGroup {
        state_identifier
        transition_start
        transition_end
        scenario_value
        scenario_info
}
modelGroup {
        model_object
        model_class
        model_operation_start
        model_operation_end
        modelValueGroup {
                model_value
        }
        oracle_start
        oracle_end
        precondition_end
        coverageGroup {
                coverage_structure
                branch
                mark
                prime_formula
                coverage_element
        }
        invariant_start
        invariant_end
        model_info
}
implementationGroup {
        implementation_object
        implementation_class
        implementation_operation_start
        implementation_operation_end
        implementationValueGroup {
                implementation_value
        }
        implementation_info
}
userInfo

In addition to the listed groups there is a pseudogroup values -- union of modelValues and implementationValues groups.

At last, one can use method {@link jatva.tracer.Tracer#setTraceAll(boolean) setTraceAll(boolean)} to switch on or off all groups at once. The top level messages (scenario_start, scenario_end, exception and internal_error) never can be off.