Report test run-time information

Relevant for: API testing only

Using custom events, you can report the run-time values or information of a given step, property, or parameter. You can choose either to report this to the Output pane or the run results. Viewing this information provides a simpler alternative to watching a object/property/parameter value while debugging.

To send run-time information, you can use the Report function or the UserLogger object.

Report a custom message to the run results

Click here to perform a sample tutorial

Using the Report function, you can send a custom message to the run results.

  1. Select the step for which you want to report information.

  2. In the Properties pane, open the Events tab .

  3. In the Events tab, create an event handler. The TestUserCode.cs file opens.

  4. In the TODO section of the TestUserCode.cs file, enter the value you want to report using the following syntax:

    this.<activity name>.Report("<report information title>", "<reported data>");

    or

    <activity name>.Report("<report information title>", "<reported data>");

    Tip: If you use the Context object after the <Activity Name> property. you report the run-time value of the selected object, property, or parameter.

The Report method displays a custom message in the step's captured data.In this example, a ConcatenateStrings test step implemented the following code in an event handler:

For example, the following code reports the value used for the Prefix property of a ConcatenateStrings activity:

this.ConcatenateStringsActivity4.Report("Run-time Prefix Value", this.ConcatenateStringsActivity4.Prefix)

Back to top

Report run-time values to the Output pane

Click here to perform a sample tutorial

Using a UserLogger object, you can view the run-time value of a particular property, parameter, or object. This value is reported in the UserLogger build log displayed in the Output pane during test compilation.

UserLogger statements are useful in place of debugging. By viewing the run-time value of the selected property, parameter, or object, you can see the actual value without having to use the more complex debugging features.

  1. Select the step for which you want to report information.

  2. In the Properties pane, open the Events tab .

  3. In the Events tab, create an event handler. The TestUserCode.cs file opens.

  4. In the TODO section of the TestUserCode.cs file, enter the value you want to report using the following syntax:

    Context.UserLogger.<user logger info level>("<object/property/parameter>");

    IMPORTANT: It is mandatory to use the Context object before the UserLogger object, as the Context object isolates the actual run-time context of the property, parameter, or object whose value you want to see.

You can then see the value you selected in the Output pane:

For example, the following code reports the run-time value of the CustomerName property (whose value comes from a data source attached to the test) in a flight booking Web service. In this example the value to be reported was set with the DataSourceValue variable.

var DataSourceValue = GetDataSource("WebServiceData!Input").GetValue(0, "CustomerName");
Context.UserLogger.Info(DataSourceValue);

Back to top