chgehmec Absent Member.
Absent Member.
857 views

HP QC: Script for automatically creating defect

Hey there,

I am pretty new in using HP QC. My problem:

I would like to have a defect generated each time, when a user sets a test-step inside a test to "failed".
The defect should automatically include cycle/release/tester who detected the defect/severity/Detected on date/status (new).

As far as I understood, this needs to be done in customization.

I've been searching the knowledge base and forums, but couldnt find an answer.

So can please somebody help me out with a script? If you need more information, i will provide them. I hope you understood my problem :S

Thank you very much in advance,
Cheers,
Chris
0 Likes
6 Replies
Knowledge Partner
Knowledge Partner

Re: HP QC: Script for automatically creating defect

Hi Chris,

Have you implemented this requirement?
If so , could you pls help with the details.

Regards,
Srihari
0 Likes
Honored Contributor.. arichtman Honored Contributor..
Honored Contributor..

Re: HP QC: Script for automatically creating defect

@Srihari- this post is 8 years old....

0 Likes
Knowledge Partner
Knowledge Partner

Re: HP QC: Script for automatically creating defect

Thanks @arichtman .

Able to force user to link defect ( either a new one or an exisitng one) to run step using the below code.

Function Step_FieldCanChange(FieldName, NewValue)
    On Error Resume Next
    
    If FieldName = "ST_STATUS" Then
        If Step_Fields("ST_ACTUAL").Value = "" Then
            MsgBox "Actual Result cannot be empty"
            Step_FieldCanChange = False
            Exit Function
       End If
        
'If the new value is going to be Failed or Blocked...
        If NewValue = "Failed" Or NewValue = "Blocked" Then
            
'Get the Step ID of the current Step.
            StepID = Step_Fields.Field("ST_ID").Value
            
'Get the Step factory from the StepID
            Set StepFact = TDConnection.StepFactory
            
'Get the Step object from the Step Factory
            Set StepObj = StepFactory.Item(StepID)
            
'Get the BugLinkFactory from the Step
            Set BugLinkFact = StepObj.BugLinkFactory
            
'Set a blank filter to find all the current defects in the BugLinkFactory
            Set BugLinkFactFilter = BugLinkFact.Filter
            
'Apply the filter and add the filtered items to a list
            Set BugLinkFactList = BugLinkFactFilter.NewList
            
'Check the list to see if it is empty
            If BugLinkFactList.Count = 0 Then
'Inform the user.
                MsgBox "You must link a defect."
'Block the status change
                Step_FieldCanChange = False
'leave
                Exit Function
End If
            
'Kill the objects
            Set BugLinkFactList = Nothing
            Set BugLinkFactFilter = Nothing
            Set BugLinkFact = Nothing
            Set StepObj = Nothing
            Set StepFact = Nothing
    End If
    End If
    On Error GoTo 0
End Function

But, my requirement is to force user to add defect to a run instead of run step is there a way to acheive this.

Please give some pointers.

Regards,

Srihari

0 Likes
Honored Contributor.. arichtman Honored Contributor..
Honored Contributor..

Re: HP QC: Script for automatically creating defect

so it looks like you'll need to first change the function it's running in from Step_FieldCanChange to Run_FieldCanChange. Then just adapt the objects and field names, no? Oh and that status check at the start seems to be irrelevant to your outcome.
0 Likes
Knowledge Partner
Knowledge Partner

Re: HP QC: Script for automatically creating defect

Hi arichtman,

I thought about this, when we modify the run status field to failed,then we can force the user to raise a defect at run level.

But here in our case , we have to force user to create defect at run level or test instance level ,when run step status is changed to failed.

Is that possible? Let me know your thoughts on this.

Regards,
Srihari
0 Likes
Highlighted
Honored Contributor.. arichtman Honored Contributor..
Honored Contributor..

Re: HP QC: Script for automatically creating defect

Hmmm - it's certainly possible to create defect entity on test run step fail.

You can use a combination of lists, lookups, run fields and constants to populate defect fields then Post() should create the defect as current user.

The problem is user input. If you need user input you will need to get creative - some options

Try to trigger events: end run, enter bug module, create new defect.
VBScript modal dialogue box prompting for values
Adjust test instance to show different fields and use those to raise defect
Use test instance moveto to block exection until defect is raised
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.