Dynamic TestSet Creation with VAPI-XP test

 

 

User's Requirement

 

The goal is to Create Automatically a TestSet consists of "Failed" and "Not Completed" test of an quicktest testset after its complete execution.

 

 

Proposed Solution

 

Insert of an automatic VAPI-XP test, at the end of the TestSet, that check all test status. It will create an automatic TestSet under Unattached folder with all the tests that are "Failed" or "Not Completed".


 

 

______________________________________________________________________________

 

Implementation on the Product

 

The scenario, in this example, provides the creation of a VAPI-XP test that must be insert into the automatic TestSet (consists of QTP Tests) to be analyzed.

This test will run on the client machine where Quality Center is running and will analyze all the QTP Tests of the Test Set, the execution status and if there is at least a Failed or Not Completed status it will create a TestSet with only those Tests in these status linked each other in sequential manner.

 

The VAPI-XP Test Creation is made from the TestPlan module selecting VAPI-XP as Test Type. We will select vbs scriptingh language that is more common for us. These are the steps:

 

1. During the creation of the test select VAPI-XP Type.

2. It will show you this form:

 

 

 

3. Use the default values (Language and Script Name) and click on "Next >>" button. It will show you this form:

 

 

 

 

4. Select "COM/DCOM Server Test" and click "Next >>" button.

 

The Creation Test Wizard shows you this form:

 

 

 

 

5. Just click "Next >>" button to go on:

 

 

 

 

Select "Finish" button to end the creation wizard of the VAPI-XP test. Now the VAPI-XP test is created but it don't do anything for the moment.

 

The Test contains vbs script code that we can see accessing to the "Test Script" tab of the test:

 

 

 

 

Let's analyze what have been created. There are comments about:

  • general information such as Name and Script Type, Date and Time Creation.
  • Into "Main Test Function" there are instructions on the objects and how to use them:
    Above "Debug", that is only a boolean variable, there are already available other objects that we DON'T have to create:
    CurrentTestSet: it's the VAPI-XP's TestSet
    CurrentTSTest: it's the the instance rappresent this VAPI-XP Test in the TestSet
    CurrentRun: it's the current execution of this VAPI-XP Test.
  • In the Main is indicated where put OWN code, under TODO label.

 

Now let's see how to check Instance Executions of this TestSet except this Test.

  1. Retrieve the Instance List (ListaTS) of the TestSet
  2. Exec a for cycle to analyze all the TestInstance Status except this one (ListaTS.Count - 1).
  3. If the Status is "Failed" Or "Not Completed" I check if the TestSet under Unattached have been already created, otherwise I'll create it.
  4. Insert the Test into the TestSet.
  5. Suppose to run all the Tests in the same Host, I'll retrieve this information from one of those instance and save it into a global variable.
  6. Copy of the Notification mode of the TestSet from the original one.
  7. Create the Dependecies between Tests of the new TestSet.

 

So under TODO section I'll put this code:

 

'1. Retrieve the TestInstance List (ListaTS)

Dim MyTempTestSet, ListaTS, i, isCreationNeed

 

'boolean variable for the creation if the temporary TestSet.

isCreationNeed = False

 

set ListaTS = CurrentTestSet.TSTestFactory.NewList("")

 

'2. For Cycle for all the Test Instance except this one.

for i = 1 to ListaTS.Count - 1

   

     '3. Checl the instance execution status. If "Failed" or "Not Completed" check if the TestSet under Unattached has been already created, otherwise I'll created

     if (ListaTS.Item(i).Status = "Failed" Or _

         ListaTS.Item(i).Status = "Not Completed") then

        

         if Not(isCreationNeed) then

            set MyTempTestSet = TDConnection.TestSetFactory.AddItem("TemporaryTestSet_" & split(Date,"/")(2) & split(Date,"/")(1) & split(Date,"/")(0))

            'Creation of a TestSet call as TemporaryTestSet_AAAAMMGG

            isCreationNeed = True

         end if

 

         '4. insert the test case using TestID property

          MyTempTestSet.TSTestFactory.AddItem(ListaTS.Item(i).TestID)

 

     end if

 

next

 

'Points 5, 6 and 7 must do only if isCreationNeed is True 

 

if isCreationNeed then

 

   '5. Copy info about HostName of Failed Tests for Tests that have been inserted in the temporary testset.

 

    'Creation of InstanceList of Temporary TestSet

    set TempListTS = MyTempTestSet.TSTestFactory.NewList("")

 

    'for cycl for each istance in the Temporary TestSet

    for each tsts in TempListTS

 

       'for cycle for each instance of the CurrentTestSet

       for each elem in ListTS

 

            if elem.TestId = tsts.TestID then
               tsts.field("TC_HOST_NAME") = elem.field("TC_HOST_NAME")
               tsts.Post
               tsts.Refresh
               exit for    'exit from the cycle because I set the info I needed.

            end if

 

        next

 

    next

  

    '6. Retrieve informations for the Notify

    MyTempTestSet.Field("CY_MAIL_SETTINGS") = CurrentTestSet.Field("CY_MAIL_SETTINGS")

 

    '7. Dependence Creation between test in the sequential order

    Dim v_CY_Desc, QuerySEQ, MyComm, RecSet

    v_CY_Desc = ""

     

       'for cycle of the temporary testset except the last test instance

       for i=1 to TempListTS.Count - 1

 

           'Source loading

           Set SourceTest = MyTempTestSet.TSTestFactory.Item(TempListTS.Item(i).ID)
           Set TargetTest = MyTempTestSet.TSTestFactory.Item(TempListTS.Item(i+1).ID)

           'Setting of the value of CY_DESCRIPTION field

           v_CY_Desc = v_CY_Desc & "{" & vbNewLine & _
                       "CN_COND_ID:" & i-1 & "," & vbNewLine & _
                       "CN_TYPE:1"  & "," & vbNewLine & _
                       "CN_VALUE:1" & "," & vbNewLine & _
                       "CN_TARGET:" & TargetTest.ID & "," & vbNewLine & _
                       "CN_SOURCE:" & SourceTest.ID & "," & vbNewLine & _
                       "CN_DESCRIPTION:" & vbNewLine & _
                       "}" & vbNewLine

 

           Set SourceTest = Nothing

           Set TargetTest = Nothing

 

       next

    

    'Set the Update Query

    QuerySEQ = "UPDATE CYCLE SET CY_DESCRIPTION = '" & v_CY_Desc & "' WHERE CY_CYCLE_ID = " & MyTempTestSet.ID & " ;"

 

     'Creation Command Object

     Set MyComm=TDConnection.Command

     'Load Query into the Command Object
     MyComm.CommandText = QuerySEQ

 

     'Query Execution  

     Set RecSet = MyComm.Execute

 

     'Destruction of the RecordSet e Command objects

     Set RecSet = Nothing

     Set MyComm = Nothing

 

     'Post and Refresh for TemporaryTestSet Object

     MyTempTestSet.Post

     MyTempTestSet.Refresh

  

     'Destruction Temporary TestSet Object

     set MyTempTestSet = Nothing

end if

 

 

Finally the creation of the VAPI-XP Test have been done. The last thing to do is to insert this VAPI-XP Test at the end of the TestSet.

 

 

Pag: <<    <    >    >>