Data Transfer from Run to Bug

 

 

User's Requirement

 

During the execution of a Test Instance, when user Create a Defect it must sends 2 Test Fields Value to the Bug: "ImportanzaTest" and "TipoTest" (TestImportance such as Low, Medium, High and TestType such as P[ositive]/N[egative]/B[atch]P[ositive]/B[atch]N[egative])

 

 

Proposed Solution

 

When the Creation Button is selected during the run of an instance Test Data have been saved into the COMMON_SETTINGS table to be exctract for the Bug.


 

 

______________________________________________________________________________

 

Implementation on the Product

 

Preamble:

This example is a very common user request. Everyone who manage Quality Center as Administrator had to deal with this task.

 

ManualRunner Module is a particular one, infact it is impossible to share global variable so the data transfer between Run to Defect must be done with external structure.

 

I will use the UserSettings object to set values to the COMMON_SETTINGS table. The useful table fields are:

  • CSET_CATEGORY
  • CSET_NAME
  • CSET_VALUE

 

To access to the category is necessary use the Open method. To set the value of the Name is necessary use the .Value("CSET_NAME") property. It is possible also to create custom category.

 

Solution:

Suppose that the 2 test fields are user fields such as:

  • TS_USER_01: Importanza Test
  • TS_USER_02: TipoTest

 

Data Transfer must be done from Test to Defect so it's necessary declare the same 2 fields into the Defect Entity. Suppose we've just created the 2 fields for the Bug: BG_USER_01 (set with the value of TS_USER_01) and BG_USER_02 (set with the value of TS_USER_02).

 

 

1. When the user select "New Bug" button will be call the sub to save test data on the COMMON_SETTINGS table

 

Function ActionCanExecute(ActionName)

On Error Resume Next

Dim Res

Res = True

 

  if ActionName = "act_add_bug" then

   'Call Sub in the ManualRun module to write test data into the COMMON_SETTINGS table

   ManualRun_Write_TestData 

  end if

 

ActionCanExecute = Res

On Error Goto 0

End Function

 

 

2. in ManualRunner Module create the Write Sub

 

Sub ManualRun_Write_TestData

On Error Resume Next

Dim uss, myTest

 

'Create the Test object using the ID from RN_TEST_ID field

set myTest = TDConnection.TestFactory.Item(Run_Fields.Field("RN_TEST_ID").Value)

 

 

'creation of UserSettings object

set uss = TDConnection.UserSettings

 

'Open the category. If there isn't it will be created

uss.Open("MyLastRun")

'Set the value of the NAME (subcategory) with Test data concatenate with "||".

uss.Value("TestData") = myTest.Field("TS_USER_01") & "||" & _

                          myTest.Field("TS_USER_02")

 

'Post&Refresh

uss.Post

uss.Refresh

 

'Close the Category

uss.Close

 

'destruction of the objects

set uss = nothing

set myTest = nothing

On Error Goto 0

End Sub

 

 

3. In the Defect Module into the Bug_New Sub I must call the function that return the values saved into the Common_Settings table

 

Sub Bug_New

On Error Resume Next

Dim ValuesFromRun

ValuesFromRun =  ManualRun_Read_TestData

 

'Set the 2 bug fields with the values returned

if instr(ValuesFromRun,"||") then   'check that it is not empty

   Bug_Fields.Field("BG_USER_01").Value = split(ValuesFromRun,"||")(0)

   Bug_Fields.Field("BG_USER_02").Value = split(ValuesFromRun,"||")(1)

end if

 

On Error Goto 0

End Sub

 

 

4. Create the function ManualRun_Read_TestData to returns the values of the 2 test fields

Function ManualRun_Read_TestData

On Error Resume Next

Dim Vals, uss

Vals = ""

 

set uss = TDConnection.UserSettings

'Open the category

uss.Open("MyLastRun")

'Load the value of "TestData" into Vals

Vals = uss.Value("TestData")

'Close the category

uss.Close

 

ManualRun_Read_TestData = Vals

On Error Goto 0

End Function

 

 

Note: I've created a Sub to write data into the COMMON_SETTINGS table and a function to read them. This because in the 1st case I don't have to return nothing, instead of the 2nd case that I need to return a value.

 

Pag: <<    <    >