UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21. Read more.
UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21.Read more.
Absent Member.. Absent Member..
Absent Member..
672 views

UFT API testing reporting

When working with API Testing in UFT I am lacking a good way to handle writing to the report programmatically. Is there anyway to write something (supported or unsupported).

 

For GUI test I use Reporter.setContext, Reporter.unSetContext, Reporter.LogEvent extensivly to get logging the way I want. Is there any possibility to do something similiar in API Testing? 

 

Or atleast be able to write something to a new report node? where you preferably can write html code to the log. 

 

I attach a picture to illustrate how I have it in GUI Testing. There instead of using UFT iterations (which I feel lack flexibility) I take care of my own iterations and by doing so am able to put a name on them Market SE, Market FI and even 10 more which was setup to not run in this test so therefor they are not displayed.

 

 

0 Likes
2 Replies
Absent Member.
Absent Member.

There is absolutely a way to do this. Instead of using the Reporter object, you use event handlers for your test step.

 

You need to do the following:

  1. In the step for which you want to write to the report, in the Properties pane, open the Events tab.
  2. In the Events tab, select the AfterExecuteStepEvent handler. Click the down arrow in that row and select Create a default handler..
  3. In the TestUserCode.cs file that opens, find the section of code that contains //TODO: Add your code here...
  4. In the place of the //TODO comment, use the Report method to send the message to the run results:
    1. Enter the this object to access the activity on which you are working. Add the period character after the this.
    2. Enter the name of the activitiy (you can find it from the intellisense list too.), followed by the period character (.)
    3. Enter the Report method with the following syntax: Report("custom feld to be entered in the results", data to be reported).

So for example, if you want to report a custom message to the run results for a Concatanate Strings activity, you can enter this example:

 

this.ConcatenateStringsActivity7.Report("My Result",this.ConcatenateStringsActivity7.Result);

 

(Don't forget the semicolon after the method syntax...)

 

Then you see this in the run results:

 

 

Hope that helps!

Note: You can find all of this in the UFT documentation (from UFT 12.00 and onward), if you need instructions and/or examples.  See this chapter:  UFT User Guide > API Testing Design > Writing Event Handlers for API Test Steps 

 

 

 

0 Likes
Absent Member.. Absent Member..
Absent Member..

Thanks for the reply. I was however aware of this approach but its not what I am after.

 

I want to create completly custom report nodes in the left side tree structure.  And I also want to write my log entry to "result details" instead of as a row in the captured data. And also I want to be able to set passed/failed/warning to the node.

 

My reason for this is

 

Say I do a REST call to an endpoint that returns a JSON with an array of data that I want to verify. Now say this array is 1000 entries large. Now I could use the GUI to manually enter which verifications I need but for 1000 entries that is pretty painful. And opening the result will be even more painful.

The nice approach would be if I can use the c# feature to loop though the results and check the values I want and then just do a log entry with passed if everything is okey, or fail and log the failing entries in a nicely formatted output (meaning preferably not plain text)

 

I am a big fan of a simple report and frankly the default logging is very cluttered so I try to remove as much as I possible can and rely on just showing but I decide is needed. I want my result files to be understandable for more people than the person that wrote the script.

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.