Skip to content

Instantly share code, notes, and snippets.

@saga
Created April 9, 2013 15:59
Show Gist options
  • Save saga/5346941 to your computer and use it in GitHub Desktop.
Save saga/5346941 to your computer and use it in GitHub Desktop.
Copy test
Private Sub CopyPasteTest(sourceFolderPath, destFolderPath, TestName)
'Copy a test, including design steps and parameters.
' For example:
' CopyPasteTest "Subject\TestFolder1", "Subject\TestFolder2", "Test1"
' Copies Test1 to TestFolder2
Dim sourceFolder As SubjectNode
Dim destFolder As SubjectNode
Dim treeMng As TreeManager
Dim testF As TestFactory
Dim iscp As ISupportCopyPaste
Dim clipboard As String
Dim aFilter 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.
Set aFilter = testF.Filter
aFilter.Filter("TS_NAME") = TestName
Set TestsList = aFilter.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
' Clean up.
Set iscp = Nothing
Set testF = Nothing
Set treeMng = Nothing
Set sourceFolder = Nothing
Set destFolder = Nothing
Set aFilter = Nothing
Set TestsList = Nothing
Set Test = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment