Sometimes it is quite useful to diagnose test failures by analyzing the respective traces. Let's describe the steps we need to take to obtain them.
Enabling automatic task management
Traces for tests are automatically stored in
storeTraceIfRequested() "after" method. Currently this method is not enabled by default. It must be enabled by including the following in the test class:
After this override is present, we should obtain
result variables in the test like this:
This has a direct advantage of simplifying the test code. And after setting up tracing in the following step, traces will be created for our test method executions.
Enabling tracing of test methods executions
By specifying the following, the pair of "before" and "after" methods will provide stored traces for our test executions:
The trace file created after the test method execution will include the operation result tree covering the whole method execution. (Assuming that we consistently use
result variable in inner method calls within the test.)
Enabling tracing of other executions during the tests
Quite often, there are other tasks executing during the tests. Either asynchronous ones (live sync, reconcile, etc), or ad-hoc tasks in the
main thread that are created separately from the test method's main task instance.
In order to trace such tasks executions we can use this e.g. in
This will cause traces to be automatically created at all traceable points. Currently these are:
Note that we can use this to trace everything also in running midPoint at any time.