Adding testcase description to test log

Originally posted by ashly on January 03, 2025

In testcomplete, is there an option to create test case descriptions in a way it can be added to the test execution report?

I am looking for solutions for adding the test case description to the test log details.

Please let me know if you have any idea how to do that.

Originally posted by rraghvani on January 03, 2025

There was a similar question a while back, unfortunately there’s no options to do this. A possible workaround is to use https://support.smartbear.com/testcomplete/docs/keyword-testing/reference/logging/index.html - use Log.AppendFolder to generate something like this,

Originally posted by scot1967 on January 03, 2025

I use the test name as my main description but I also wrap tests within Log.AppendFolder(“My Description”) and Log.PopLogFolder(). I am not sure why the ‘Description’ field in the Execution Plan does not provide this feature. SmartBear?

https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log/methods.html

I have also used script to change the fonts for the messages using the LogAttributes Object.

https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log-attributes/index.html

Here is some code for various attribute changes you can make.

/*#################### Class Attributes ################
  Class Name: Attributes
  Description: Contains methods to format Log messages.
  Arguments: None
  Methods Return: attr object
#########################################################*/

class Attributes
{

  /*#################### Method CorrectRGBComponent ################
    Method Name: CorrectRGBComponent
    Description: Accepts a component value converts it to an integer and ensures it is >= 0 and <= 255
    Arguments: a single component value
    Methods Return: integer representing an RGB color component between 0-255.
  #########################################################*/  
  
  static correctRGBComponent(component)
  {
    try
    { 
      component = aqConvert.VarToInt(component);
      if (component < 0)
        component = 0;
      else
        if (component > 255)
          component = 255;
      return component;
    }
     catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  } 

  /*###################### Method rgb #####################
    Method Name: rgb
    Description: Accepts rgb values and returns color 
    Arguments: r, g, b component values
    Methods Return: color value
  #########################################################*/  

  static rgb(r, g, b)
  {
    try
    { 
      r = this.correctRGBComponent(r);
      g = this.correctRGBComponent(g);
      b = this.correctRGBComponent(b);
      return r | (g << 8) | (b << 16);
    }
    catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  } 
  
  /*################# Method TestCaseFolder ###############
    Method Name: TestCaseFolder
    Description: Returns attributes used for a Test Case Folder
    Arguments: None
    Methods Return: attributre object
  #########################################################*/  
  
  static caseFolder()
  {
    try
    {   
      let attr = Log.CreateNewAttributes();
      attr.FontColor = this.rgb(1,1,1);
      attr.BackColor = this.rgb(199, 207, 219);
      attr.Bold = true;
      return attr;
    }
    catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  }
 
  /*################# Method StepFolder ###############
    Method Name: StepFolder
    Description: Returns attributes used for a Step Folder
    Arguments: None
    Methods Return: attributre object
  #########################################################*/    
  
  static stepFolder()
  {
    try
    { 
      let attr = Log.CreateNewAttributes();
      attr.FontColor = this.rgb(1,1,1);
      attr.BackColor = this.rgb(230, 231, 237);
      attr.Bold = true;
      return attr;
    }
    catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  }   

  /*################# Method LogFolder ###############
    Method Name: LogFolder
    Description: Returns attributes used for a Log Folder
    Arguments: None
    Methods Return: attributre object
  #########################################################*/    
  
  static logFolder()
  {
    try
    { 
      let attr = Log.CreateNewAttributes();
      attr.FontColor = this.rgb(1,1,1);
      attr.BackColor = this.rgb(230, 231, 237);
      attr.Bold = false;
      return attr;
    }
    catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  }   

  /*################# Method GreenComment ###############
    Method Name: LogFolder
    Description: Returns attributes used for a Log Folder
    Arguments: None
    Methods Return: attributre object
  #########################################################*/    
  
  static greenComment()
  {
    try
    { 
      let attr = Log.CreateNewAttributes();
      attr.BackColor = clGreen;
      attr.FontColor = this.rgb(1,1,1);  //clBlack and rgb(0,0,0) changes to white with Dark mode...
      attr.Bold = true;
      return attr;
    }
    catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  }     
  
  /*################# Method yellowComment ###############
    Method Name: LogFolder
    Description: Returns attributes used for a Log Folder
    Arguments: None
    Methods Return: attributre object
  #########################################################*/    
  
  static yellowComment()
  {
    try
    { 
      let attr = Log.CreateNewAttributes();
      attr.BackColor = clYellow;
      attr.FontColor = this.rgb(1,1,1); //clBlack and rgb(0,0,0) changes to white with Dark mode... 
      attr.Bold = true;
      return attr;
    }
    catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  }
   
  /*################# Method redComment ###############
    Method Name: redComment
    Description: Returns attributes used for a Log Folder
    Arguments: None
    Methods Return: attributre object
  #########################################################*/    
  
  static redComment()
  {
    try
    { 
      let attr = Log.CreateNewAttributes();
      attr.BackColor = clRed;
      attr.FontColor = this.rgb(1,1,1); //clBlack and rgb(0,0,0) changes to white with Dark mode... 
      attr.Bold = true;
      return attr;
    }
    catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  }
  
  /*################# Method boldFont ###############
    Method Name: boldFont
    Description: Returns attributes used for a Log Folder
    Arguments: None
    Methods Return: attributre object
  #########################################################*/    
  
  static boldFont()
  {
    try
    { 
      let attr = Log.CreateNewAttributes();
      attr.Bold = true;
      return attr;
    }
    catch(err)
    {
      Log.Error("Exception:  "+err.message);
    }
  }
}

module.exports.Attributes = Attributes;

Originally posted by scot1967 on January 03, 2025

Example Attribute_File use…

let WWPointOfSale_File = require("WWPointOfSale_File"); 
let Attributes_File = require("Attributes_File");
let WWString = require("WWString");

// Script Fragment

function TC7590_VerifyRefNumberAndPaymentType()
{
  try 
  {
    let attr = new Attributes_File.attributes_File();       
    Log.AppendFolder("TC7590_VerifyRefNumberAndPaymentType")      
      let btnCancel = undefined;      
      Log.AppendFolder("1. Login to Point Of Sale application.","",pmNormal,attr.stepFolder()); 
        let Application = new WWPointOfSale_File.WWPointOfSale_App(); 
        Application.Open_App();
        let frmMain = Application.frmMain();
        frmSale = Application.frmSale();
        frmSaleCurrentObject = frmSale.CurrentObject;
        if(typeof frmSaleCurrentObject == "object"){
          if (frmSaleCurrentObject.Exists == true){
            btnCancel = frmSale.btnCancel().CurrentObject;
            btnCancel.Click();
          }
        }
      Log.PopLogFolder();    

Originally posted by Marsha_R on January 03, 2025

You can check to see if it’s already suggested here and vote for it or you can add it yourself if it’s not.

TestComplete Feature Requests | SmartBear Community

Originally posted by Hassan_Ballan on January 03, 2025

To address such need, I personally utilized a combination of actions to reflect and make execution log readable:
1-Project Name
2-Introduce test case specific log entry by using “Log Message”
3-Introduce log foldering by using “Append Log Folder” with “Pop Log Folder”, and “Log Attributes”

Originally posted by scot1967 on January 06, 2025

I don’t see documentation for the description field in the Execution Plan docs. If I add the column and put text there it removes the text when I save, run the project or run the focused item. What is it for?

https://support.smartbear.com/testcomplete/docs/working-with/managing-projects/execution-plan/test-item-list.html

I just found this but not why I can’t set the description property in the Execution Plan for the project. Maybe I am just misunderstanding the purpose of the field and it’s intended use. I know this field does not show up in the test log or run summary.

https://support.smartbear.com/testcomplete/docs/reference/project-objects/project/testitem/index.html

Originally posted by rraghvani on January 06, 2025

It appears in the Details tab

Originally posted by scot1967 on January 06, 2025

Indeed! I forgot about the properties panel hidden on the right side. The description text will stick if entered here instead of double clicking the Execution Plan grid.

Originally posted by jrsbr on January 09, 2025

I use a meanigfull test name plus we have a convention to add a log message at the start and end of all tests and support procs. It would be nice if the description was added the calling side as well in the comments, or even if the comments were included in the log.