Private Function AddAndEditTest(TestName$, _ Optional TestType = "SYSTEM-TEST", _ Optional ByRef containingFolder As SubjectNode) As Test ' Create a test and change some properties ' Create new test. ' This example assumes that the subject folder containing the ' new test is directly under the root "Subject" folder. Dim objTest As Test Dim testF As TestFactory Dim SubjRoot As SubjectNode On Error GoTo FUNC_ERR Set AddAndEditTest = Nothing If containingFolder Is Nothing Then 'Create a folder Set containingFolder = GetTestSubjectFolder("Add_And_Edit_Folder") End If Set testF = containingFolder.TestFactory Dim tFilter As TDFilter, tList As List, qTName As String ' Check if the test already exists Set tFilter = testF.Filter qTName = """" & TestName & """" tFilter.Filter("TS_NAME") = qTName Set tList = tFilter.NewList() Dim aT As Test For Each aT In tList If aT.name = TestName Then Set objTest = aT Exit For End If Next aT ' If test does not exist, create it If objTest Is Nothing Then Set objTest = testF.AddItem(Null) objTest.name = TestName objTest.Type = TestType objTest.Post End If Dim VerCtl As VCS Dim bIsLocked As Boolean Dim strLockedBy As String Set VerCtl = objTest.VCS VerCtl.Refresh bIsLocked = VerCtl.IsLocked strLockedBy = VerCtl.LockedBy ' After POST, Test is checked in. Debug.Print "Version is locked: " & bIsLocked 'Is locked: False Debug.Print "Version locked by: """ & strLockedBy & """" 'Is locked by: "" VerCtl.CheckOut -1, "To change state", True VerCtl.Refresh bIsLocked = VerCtl.IsLocked strLockedBy = VerCtl.LockedBy Debug.Print "Version is locked: " & bIsLocked 'Is locked: True Debug.Print "Version is locked by: """ & strLockedBy & """" 'Is locked by: "User1" ' Take an arbitrary field to change. Debug.Print "Status: """ & objTest.Field("TS_STATUS") & """" 'Status: "" objTest.Field("TS_STATUS") = "Ready" objTest.Post VerCtl.CheckIn "", "Changed status" VerCtl.Refresh bIsLocked = VerCtl.IsLocked strLockedBy = VerCtl.LockedBy Debug.Print "Version is locked: " & bIsLocked 'Is locked: False Debug.Print "Version is locked by: """ & strLockedBy & """" 'Is locked by: "" Set AddAndEditTest = objTest Exit Function FUNC_ERR: Set AddAndEditTest = Nothing End Function