In some cases, it is useful to conceal some of the messages in the log in such a way that they are not seen all the time, rather than have them be easily accessible. For example, in case of looping through the lines of the table to locate the needed one, we could place each indexed line into the log; however, they could be rather a lot in number, making it unnecessary to view them on the top-level all the time.
To resolve this issue, TestComplete extends a possibility to create special folders in the log, where the messages could be successfully placed.
The following steps should be performed to create folders in the log:
Log.CreateFolder
is to be used, the folder name expected to be passed as a parameter:var folder = Log.CreateFolder("1st folder");
Log.PushLogFolder
:Log.PushLogFolder(folder); Log.Message("This message will appear in the 1st folder"); Log.Event("This event will appear in the 1st folder");
Log.PopLogFolder
is to be utilized:Log.PopLogFolder(); Log.Message("This message will appear in the root folder");
In the result, the log will assume the shape and form as shown in the following screenshot:
The method of Log.CreateFolder
returns an integer (Folder ID
), which uniquely identifies the folder. With the help of the Log.PushLogFolder
method, we enable the folder, whose Folder ID has been signified as a parameter.
The folder can be nested inside each other as many times as necessary, thus segregating the information in the log by levels (low-level operations will be the most nested, while the operations of the upper level will be nested above).
Such an approach is really handy, for example, in the case that each test provides a number of steps. Each step will be located on the upper level, while the details of the operations will be hidden out of view. Using such an approach, if an error has emerged, it is easy to see all of it at once: what stage did the error spring up on, since (in case of error generation in the nested folder) the sibling elements are also displayed with an error sign, or with a warning sign, depending on the type of error generated.
If you need to send a one-off message into the closed folder, it is not necessary to open it and then close it. All the message methods of the log accept an optional parameter of Folder ID, with the help of which one could place messages into the assigned folder. For example, if we had a folder created, as in the previous example, we can place a message into it in the following manner:
Log.Message("Posting message to the specified log folder", null, pmNormal, null, null, folder);
Here, we pass only the message priority (pmNormal
) and the folder identifier (folder
), all the optional parameters are set to null
, which implies that default values will be used.
18.216.27.251