Testresult Comments

Table of Contents

Using a testcase-script, you can write comments to every testresult. These comments are displayed in the testresult-dialog and help you to recognize a specific testcase-instance and separate them visually from each other.

Imagine a testcase that you run multiple-times (multiple-instances). One instance for each of your sales-territories for example.

Without setting a comment, you will only see multiple testresults in the testresult-dialog. There is no way to recognize the specific sales-territory of a testresult without drilling down into the details. You can see that in the following screenshot.

To make each of these testresults clearly understandable, you can set a comment for each using the following syntax. See the full-example at the bottom of this article to understand the full context.

SetComment($"Sales Territory: {salesTerritoryName} ({salesTerritoryId})");

Now you will see the following testresults. All sales-territories are clearly visible what makes the analysis much more efficient.

Full Example

The following example testcase-control-script runs the testcase for each sales-territory available from the ERP-system. Please note that we do not show the parametrized probes needed for running this testcase successfully, because we are discussing the commenting feature in this article.

// Query the available sales territories from the ERP.
var salesTerritories = QueryTable("AW ERP", "SELECT TerritoryID, Name FROM Sales.SalesTerritory ORDER BY TerritoryID");

// Loop through the sales-territories.
foreach(DataRow salesTerritory in salesTerritories.Rows)
  // Extract ID and Name of the current sales territory.
  var salesTerritoryId = (int)salesTerritory["TerritoryID"];
  var salesTerritoryName = salesTerritory["Name"].ToString();

  // Write a comment to the test-result to show the current sales-territory.
  SetComment($"Sales Territory: {salesTerritoryName} ({salesTerritoryId})");

  // Push sales-territory-parameter to the probe-queries.
  SetParameter("SalesTerritoryId", salesTerritoryId);

  // Execute the test.
  await ExecuteAsync();