Do you need your test scripts to save test files in QC? Or do you may have a file that contains test data that you want your scripts to read from? Yesterday I received an email form my blog friend Kumar that asked how this can be done using Quality Center and QTP. Hopefully this post will explain how this functionality can be achieved. You also might want to check out How to use QTP to save and retrieve a Quality Center Test Resource
Steps to attach a file in QC
1. In QTP Create a new test named TestLabAttachment and save in a folder in Quality Center:
2. In QC add the QTP script ‘TestLabAttachment’ into a test set in the QC ‘Test Lab” section
3. Create a local text file on your QTP machine that you want to add to the QC ‘Attachments’ tab. For example:
3. In QTP add the following lines of code:
Set nowTest = QCUtil.CurrentTestSet
Set attachmentPath = nowTest.Attachments
Set nowAttachment = attachmentPath.AddItem(Null)
‘Replace with the path to your file:
nowAttachment.FileName = “C:\QTPAUTOMATION\DATA\testenv.txt”
nowAttachment.Type = 1
4. Run QTP script. In the Run dialog select ‘Results Location’ tab and click on ‘New run Results in QC project”. Select the Test Set that the current script is saved in.
5. After the QTP script runs go back to QC and look under the test set’s ‘Attachments’ tab. The file should appear:
Steps to retrieve file from the QC Test Set ‘Attachments’ tab
- Open QTP
- In the same script that you created above TestLabAttachment enter the following code (“I admit this code is ugly – but it works. If you know a better way please let me know”)
- Run QTP script. In the Run dialog select ‘Results Location’ tab and click on ‘New run Results in QC project”. Select the Test Set that the current script is saved in.
4. After the QTP script runs go the folder where you saved your file. The QC file should now be in it.
Also be sure to check out Application Lifecycle Management for the Whole Team