Sunday, February 27, 2011

How to Create a Test using OTA

Working with TestFactory objects using OTA API

'Get or create test plan subject folder
errmsg = "Subject tree error"
Set root = TreeMgr.TreeRoot("Subject")
On Error Resume Next
Set folder = root.FindChildNode(FolderName)
On Error GoTo LinkDefectsToEntitiesErr

If folder Is Nothing Then _
Set folder = root.AddNode(FolderName)

'Create a design test
errmsg = "Design test error"
'Get the test if it exists
' For the code of GetTest, see the Test object example
' "Get a test object with name and path"
Set NewTest = GetTest(TestName, FolderName)
'If it doesn't exist, create it

If NewTest Is Nothing Then
Set NewTest = TestF.AddItem(Null)
NewTest.Name = TestName
NewTest.Type = "MANUAL"
'Put the test in the new subject folder
NewTest.Field("TS_SUBJECT") = folder.NodeID
NewTest.Post
End If

'Get or create a design step from the factory of the new test
errmsg = "Design step error"
Set StepF = NewTest.DesignStepFactory
Dim aFilter As TDFilter
Set aFilter = StepF.Filter
Dim StepName$
StepName = TestName & "Step_1"
aFilter.Filter("DS_STEP_NAME") = StepName
Set lst = StepF.NewList(aFilter.Text)
If lst.Count = 0 Then
Set desStep = StepF.AddItem(Null)
desStep.StepName = StepName
desStep.StepDescription = "Step to be linked to defect."
desStep.StepExpectedResult = "This step expected to be linked."
desStep.Post
Else
Set desStep = lst.Item(1)
End If

2 comments:

  1. really appreciate your efforts. It is really nice document and i am able to clear my alldoubts about OTA objects.
    Well done

    ReplyDelete
  2. really appreciate your efforts. It is really nice document and i am able to clear my alldoubts about OTA objects.
    Well done

    ReplyDelete