Message posted to wrong log folder
Hi,
I'm completely clueless what this strange behavior is posted by: I append a log folder to the one on the top of the folder stack, but TC only posts entries to this appended folder only when explicitly specifying its ID, otherwise it posts to the top level.
Here's the code producing the issue:
function ReadGlobalConfig() { DumpCommandLineParams(); var logId; Log.PushLogFolder(GetInfrastructuralLogID()); logId = Log.AppendFolder("Reading project suite configuration settings"); // Method 1 ProjectSuite.Variables.BaseTestDataPath = GetSetting("Environment", "BaseTestDataPath", ProjectSuite.Variables.BaseTestDataPath); Log.Message("Base path for master copies of test data: " + ProjectSuite.Variables.BaseTestDataPath, null, pmLowest); // Method 2 ProjectSuite.Variables.BaseTempPath = GetSetting("Environment", "BaseTempPath", ProjectSuite.Variables.BaseTempPath); Log.Message("Temporary folder base path: " + ProjectSuite.Variables.BaseTempPath, "", pmLowest, null, null, logId); // Method 1 ProjectSuite.Variables.BaseResultsPath = GetSetting("Environment", "BaseResultsPath", ProjectSuite.Variables.BaseResultsPath); Log.Message("Base path of results: " + ProjectSuite.Variables.BaseResultsPath, null, pmLowest); Log.PopLogFolder(); Log.PopLogFolder(); // Infra log }
I maintain two top-level log folders, one for events occured during the core steps of the tests, and an infrastructural log for log entries which are likely coupled with test configuration or errors. I also use this infrastructural log folder to document command-line parameters and configuration settings.
The method in the sample above:
- Pushes the infrastructural log to the top of the folder stack. The method GetInfrastructuralLogID() returns the ID of the infrastructural log golder.
- Appends a folder for the subsequent messages.
- Logs messages using two different methods, for testing.
- Pops the folder appended in step 2.
- Pops the folder pushed to top in step 1.
Now the weird result is that the entry posted using Method 2 appears in the correct subfolder appended. But if I do not specify the log folder ID, the entries are posted to the topmost level folder of the entire test run (that is, out of the complete infra log folder), as trying to show here:
+ Test Log - Entry + Subfolder - Enntry + Infrastructural log - Entry + Reading project suite configuration settings - The second entry posted using method 2 - The first entry posted using method 1 - The third entry posted using method 1
I've never faced such strange situation, but I miss something trivial. Do you have any idea?
A simple test shows that calling Log.PushFolder() on the same folder twice does actually push that folder twice onto the stack. Popping it off twice is appropriate. (attached the foldertest that I used)
I can reproduce your problem only if I push an invalid folder ID:
function ReadGlobalConfig() { var GetInfrastructuralLogID = Log.CreateFolder("GetInfrastructuralLog", null, pmLowest); Log.PushLogFolder(GetInfrastructuralLogID); var logId = Log.AppendFolder("Reading project suite configuration settings"); var invalidID = 5; Log.PushLogFolder(invalidID); Log.Message("Method 1", null, pmLowest); Log.Message("Method 2", "", pmLowest, null, null, logId); Log.Message("Method 1", null, pmLowest); Log.PopLogFolder(); Log.PopLogFolder(); // Infra log }
Other than that, I've got nothing.