I'm trying to work out an automated way to copy test cases from the test plan module to the same folder structure in a different project. In particular Quick Test Professional tests. I have been able to write code that will save all the quicktest tests to the folder system but have not been able to work out a way as yet to save the tests back up to Quality Center in a different project.
I was hoping there would be an eaiser way to copy the tests accross. we are using QC 9.2
Any ideas would be appreciated
I haven't tried this before, so take my advice at your own risk.
Reviewing the OTA API documentation for QC v9.2, it appears that test scripts for a tests are accessed through the ExtendedStorage property of the Test object. Seems to me that using the API you could extract all the test case information using a TDConnection to the source project and using the Test object and its child objects/methods/properties. Then you could use another TDConnection object to add all that information to the destination project.
(Opinions and information contained in this post are wholly my own and do not reflect the opinions of my employer.)
I can create a blank QTP test in a specific QC folder using the code below however having issues trying to work out how I can upload an existing QTP test on the loacl disk to the test. I have had a bit of a read about the extendedstorage as suggested but can't work out how to reference the QTP test on the local disk. Any feedback would be very appreciated
Set oTreeM = TDConnection.TreeManager
set folder = oTreeM.NoteByPath(strDestFolder)
set testF = folder.TestFactory
Set test1 = testF.AddItem(Null)
test1.Name = "Test Name5"
test1.type = "QUICKTEST_TEST"
Set TestStorage = test1.ExtendedStorage
Not sure how well it works cross project or with a quicktest test but you can use the API to copy a test to the clipboard and paste it back into another folder ...
Dim iscp As ISupportCopyPaste
Dim clipboard As String
Dim Filter As TDFilter
Dim TestsList As List
Dim Test As Test
Set treeMng = tdc.TreeManager
Set sourceFolder = treeMng.NodeByPath(sourceFolderPath)
Set testF = sourceFolder.testFactory
'find the test id if necessary
If IsNumeric(testName) Then
Set Test = testF.Item(testName)
Set Filter = testF.Filter
Filter.Filter("TS_NAME") = testName
Set TestsList = Filter.NewList()
Set Test = TestsList.Item(1)
'copy the source test
Set iscp = testF
clipboard = iscp.CopyToClipBoard(Test.ID, 0, "")
'paste the test in the destination folder
Set destFolder = treeMng.NodeByPath(destFolderPath)
Set testF = destFolder.testFactory
Set iscp = testF
iscp.PasteFromClipBoard clipboard, destFolder.NodeID
I've not actually used the code above, started it for something once upon a time then got side tracked and never finished it so not sure if it works. Should be easy enough to adapt to cross project. You might need to combine it with using the attachments factory to copy across any function libraries etc.
I have tried similar code and keep getting 'Object Does not support this property or method' error when executing from Excel VBA. Does anyone know what reference needs to be aded to Excel to use the CopyToClipboard method
1. I'm curious about that requirement to "copy test cases from the test plan module to the same folder structure in a different project. In particular Quick Test Professional tests. [...] We are trying to develop an automated way to do it as it is a common task for us."
It looks like there is some place for improvement in your current process.
2. If your tests are all QTP tests, you could use the QTP Automation Object Model to save the test locally and then save it to the new project. This would be more efficient than the other methods proposed in this thread :
a. Copy / Paste requires that you connect to the source project, copy, connect to the destination project, paste. You'd have to do that for each test to be copied. Using a local save would require just one connect to the source and destination projects.
b. Using the ExtendedStorage property of the QC test object would also copy all results directories, which reside in the directory tree for the QTP test.
3. However, the preferred method is a manual copy / paste. If all your tests are attached to the same test subject in the test plan, you can copy that subject and paste it. Another option is to apply a filter to the test plan so that only the tests you need will be copied. Yet another option, if the tests to be copied are in a test set (or a set of test sets under the same test set folder) in the test lab, is to copy that test set (or test set folder) and paste it : the tests will be copied as well. You can also filter the test set folder structure...