How to generate Description.tcLog before executing the next node in TestComplete?

Originally posted by Gonzivilla on January 29, 2025

Hi everyone,

I’m working with TestComplete and I’m facing an issue where the Description.tcLog file is not generated until the entire execution of the test suite is finished. I have separated actions into different nodes, but the log file is only generated after all nodes complete.

I specifically need the Description.tcLog file because I’m extracting certain data from it that I need to transfer to an Excel file. However, the issue is that the data isn’t available until the entire execution finishes.

Is there any way to ensure that the Description.tcLog file is generated after a specific node’s execution, so that I can then extract the data and move forward with the next steps, like transferring this data to Excel?

Any advice or best practices would be greatly appreciated!

Thanks!

Originally posted by rraghvani on January 29, 2025

It’s function as designed. A possible workaround is to execute your tests individually.

Originally posted by Hassan_Ballan on January 29, 2025

As rraghvani stated it is working as designed and you could use the command line to run individual tests in sequence https://support.smartbear.com/testcomplete/docs/working-with/automating/command-line-and-exit-codes/command-line.html

Originally posted by scot1967 on January 29, 2025

Maybe this?

https://support.smartbear.com/testcomplete/docs/working-with/managing-projects/properties/log.html

Originally posted by scot1967 on January 29, 2025

TestComplete is also capable of creating and writing data directly to Excel from your scripts as well as creating files in the file system. Hit me up if you want to know more.

Originally posted by Hassan_Ballan on January 29, 2025

Gonzivilla I am curious to what your are reading from the log to add to Excel, maybe there is a different approach.

Originally posted by Gonzivilla on January 30, 2025

Hi Hassan_Ballan,

I am extracting specific data from the Description.tcLog file and transferring it to an Excel file. The challenge is that the Description.tcLog file is not generated until the entire execution of all the nodes is complete.

What I need is for the log to be recorded after each node finishes, so that when the first node is done, the log can be written. After that, the next node for processing the data in Excel can run, retrieving the log data from Description.tcLog.

I hope that clarifies the issue! Let me know if you have any suggestions for an alternative approach.

Thanks!

Originally posted by rraghvani on January 30, 2025

What is the actual purpose of the Excel file having the following information?

What do you intend to do with this information?

Originally posted by Gonzivilla on January 30, 2025

Hi rraghvani The purpose of storing this information in the Excel file is to capture the test ID, the test name, whether the test passed successfully, and the test version. This information is used to create a detailed report on the status of the executed tests.

My goal is to retrieve the test name along with its ID, and its result, and store this information in the Excel file for reporting purposes.

Originally posted by scot1967 on January 30, 2025

It looks like you are reading the nodes in the log file and trying to ensure a new node is created after each test case to obtain the result to write to Excel as the test project runs. If you are scripting the test cases adding a few Excel calls in a function you can call from your scrips may be the best way to go. The log will only be updated at the end of the run or at intervals you define in the project.

These are a few JavaScript functions to check for existence and write data to Excel. You can mod this and call it as needed. In your case, I would add a call at test start, in a catch to log failures, and in the last line when the test case completes.

function Write2Excel(_valuesObj,_fileName,_sheetName)
{
  let excelFile = undefined;
  let excelSheet = undefined;

  if (!aqFile.Exists(_fileName))
  {  
    // Create a new Excel file and add a new empty sheet to it
    Log.Message(aqString.Format("The %s file does not exist and will be created.", _fileName));
    excelFile = Excel.Create(_fileName);
    excelSheet = excelFile.AddSheet(_sheetName);
    excelFile.Save();
  }  
  
  if (aqFile.Exists(_fileName))
  {
    // Open the existing Excel file
    excelFile = Excel.Open(_fileName);

    if(SheetWithTitleExists(excelFile,_sheetName) == false)
    {
      excelSheet = excelFile.AddSheet(_sheetName); 
    }
    else
    {
      excelSheet = excelFile.SheetByTitle(_sheetName);    
    }
    
    Object.entries(_valuesObj).forEach(([key, value]) => 
    {
      if(excelSheet.RowCount == 0)
      {
        // Write the header row
        Object.entries(value).forEach(([key, value]) =>
        {
          //Write Line Item Values to rows. 
          let cellData = "";
          Object.entries(value).forEach(([key, value]) =>
          {
            cellHeader = key;
            cellData = value;

          });
          excelSheet.Cell(key, 1).Value = cellHeader;        
          excelSheet.Cell(key, 2).Value = cellData;
        });
      }
      else
      {
        rowIndex = excelSheet.RowCount + 1;      
        Object.entries(value).forEach(([key, value]) =>
        {
          //Write Line Item Values to rows. 
          let cellData = "";
          Object.entries(value).forEach(([key, value]) =>
          {
            cellData = value;
          });
          excelSheet.Cell(key, rowIndex).Value = cellData;        
        });
      }
    });  
  }
  // Save the file to apply the changes
  excelFile.Save();
  //Excel.Close(fileName);
}

function SheetWithTitleExists(_fileName,_sheetName)
{
  if (! equal(_fileName, null))
  {
    if (_fileName.SheetCount > 0)
    {
      for (let i = 0; i < _fileName.SheetCount; i++)
      {
        if (equal(_fileName.SheetByIndex(i).Title, _sheetName))
        {
          return true;
        }
      }
      return false;
    }
    else
    {
      return false;
    }
  }
}

module.exports.Write2Excel = Write2Excel;
module.exports.SheetWithTitleExists = SheetWithTitleExists;

Originally posted by scot1967 on January 30, 2025

You could also look into using the Events in TestComplete so you only need to do these calls in the events.

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/handling-events/about.html

There are many events here you can use to call functions to write data to an Excel file. There is also a OnLogCreateNode and OnLogCloseNode which I have never used but may be EXACTLY what you need. I don’t know when they fire however.

Originally posted by Hassan_Ballan on January 30, 2025

If I have a good understanding of all the provided details, it would seem to me that you are going out of your way to log specific run data to TestComplete log, and than build a report by extracting such log data to place in Excel sheet.

To avoid clashing with the beast nature, I see that you only have two options:

1-Build report as you go
As other members pointed out, would it not be simpler for you to write to Excel directly as your run is proceeding similarly to writing to the default log?
You can modify your existing code to, as you write the message to the log also write it to Excel. At least that is how I would go about it.

2-Build report when run is completed
Have two runs back to back, you current project and another project to go thru all the previous project logs to read and build the report

Originally posted by rraghvani on February 03, 2025

You don’t need to read Description.tcLog as this is a specific file to TestComplete. You can either use the command line parameters /ExportLog or /ExportSummary to output the results.

You can save historical resultsEach historical results, has test execution summaryAnd includes detailed results

You can also create your own custom report, via reading and parsing the .XML summary report file

Email of test summary