One of the possible applications for capturing events is regular saving of the log to HDD to avoid the loss of results against unforeseen situations (blackouts, emergency TestComplete termination, and so on). This is particularly important in big projects, where there are many tests being executed and results being checked regularly.
In this recipe, we will consider how to store the log as each test completes.
To save the results after each test execution is over, it is necessary to perform the following steps:
OnStopTest
event.Log.Event("Saving results to disk"); Log.SaveToDisk();
function Test1() { Log.Message("Test 1"); }
In the result, a log will be instanced, thereby the results of each test execution will be saved to HDD (this is easy to verify by checking for the message at the end of each test):
Saving the log to HDD is possible at any given moment of time by invoking the Log.SaveToDisk
method.
We are doing so at the end of each test, using the
OnStopTest
event. Pay attention that the event is triggered at the end of each test and launched via test items. If you simply launch the function from which you call several tests, the event will fire just once (as each invoked function completes its call), rather than upon each invoked test. For example:
function TestAll()
{
Test1();
Test2();
// OnStopTest
}
3.133.134.17