ALM How to Populate Expected Actual Results in Test Run’s History

Software Testing Published on:
Code Hacker

Problem – How do I populate the QC Steps Details?

I'll be honest: for a while, I had no idea how to populate the QC Step Details for the test results of a QTP test script.


I was stumped. I thought maybe there was a secret parameter for the QuickTest Pro reporter function that I was missing. I knew there must be a way to do it using QC/ALM's OTA API, but I never got around to figuring out — until now.

FDA Reporting and ALM Back story

While working on a project for a medical device, one of the requirements was that test result be formatted in a way that would satisfy an FDA audit. Luckily, this was accomplished using OTA.

This is what I found out:

Quality Center's OTA StepFactory to the Rescue

Turns out it's pretty easy to add this info to a test run's results history for the step details. All you need to do is tap into the OTA's CurrentRun and StepFactory objects.

Once you have an instance of the StepFactory object, it's then just a matter of adding your values to the ST_EXPECTED and ST_ACTUAL fields.

For example — the following code will populate all the fields in the QC/ALM test lab test run step details:

Set myCurentRun = QCUtil.CurrentRun
Set myStepFactory = myCurentRun.StepFactory
myStepFactory.AddItem("Joe Debug Test Step")
Set myStepList = myStepFactory.NewList("")
stepID = myStepList.Count
myStepList.Item(stepID).Field("ST_STATUS") = "PASSED"
myStepList.Item(stepID ).Field("ST_DESCRIPTION") = "This is a debug test step"
myStepList.Item(stepID).Field("ST_EXPECTED") = "Joe"
myStepList.Item(stepID ).Field("ST_ACTUAL") = "Joe"
myStepList.Post


Next, roll it up and make a reusable QTP function that can be used by all your scripts. Since I need to use this pretty often, I create a function that I could reuse. The function's code is:

'-------------------------------------------------------------------------------
' @Function Name:reportFDA stepName,status,desc,expectedResult,actualResult
' @Documentation:Values to enter for possible FDA audit
'-------------------------------------------------------------------------------
Function reportFDA(stepName,status,desc,expectedResult,actualResult)
Set myCurentRun = QCUtil.CurrentRun
Set myStepFactory = myCurentRun.StepFactory
myStepFactory.AddItem(stepName)
Set myStepList = myStepFactory.NewList("")
nStepKey = myStepList.Count ' This sets step count
myStepList.Item(nStepKey).Field("ST_STATUS") = status
myStepList.Item(nStepKey).Field("ST_DESCRIPTION") = desc
myStepList.Item(nStepKey).Field("ST_EXPECTED") = expectedResult
myStepList.Item(nStepKey).Field("ST_ACTUAL") = actualResult
myStepList.Post
' Clean up.
Set myStepList = Nothing
Set myStepFactory = Nothing
Set myCurentRun = Nothing
End Function
'----------------------------------------------------------------

HEY, HEY, HEY! IT'S OTA!

That's it! With some simple OTA I was able to get the results format I was looking for.

Code Hacker