Forum Discussion

Gonzivilla's avatar
Gonzivilla
Occasional Contributor
9 days ago

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

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!

  • scot1967's avatar
    scot1967
    Regular Contributor

    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.

    • Hassan_Ballan's avatar
      Hassan_Ballan
      Regular Contributor

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

      • Gonzivilla's avatar
        Gonzivilla
        Occasional Contributor

        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!

         

  • rraghvani's avatar
    rraghvani
    Champion Level 3

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

     

    • Gonzivilla's avatar
      Gonzivilla
      Occasional Contributor

      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.

      • Hassan_Ballan's avatar
        Hassan_Ballan
        Regular Contributor

        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

  • scot1967's avatar
    scot1967
    Regular Contributor

    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;