Highlighted
Absent Member.
Absent Member.
815 views

Define one “Test configuration” to multiple “Tests”

Jump to solution

Hi,

 

Is it possible to assign single "Test configuration" to multiple "Tests" (100+) without editing each test manually?

 

Regards,
Dmitri

 

PS: Go to the ready script

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Define one “Test configuration” to multiple “Tests”

Jump to solution

It is not complicated to do this using the OTA API. Assuming you have created a list of the tests for which you want to add the configurations, in VBScript

 

For each tst in tstlist                
      Set newConfig =  tst.TestConfigFactory.AddItem(NULL)
      newConfig.Name = "Windows 10"
      newConfig.Post
      Set newConfig = Nothing
Next
       

 

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]

View solution in original post

6 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Re: Define one “Test configuration” to multiple “Tests”

Jump to solution

Hi Dmitry,

 

Default Test Configuration is automatically created upon Test creation. Thus in your case you would need to modify the default test configuration for each test.

 

I believe you can achieve this with OTA API script (maybe SQL request as well).

 

What to you want to modify in the Test Configuration?

 

BR,

 

Deyan

[Give Kudos or accept as Solution, if post helped you :)]
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Define one “Test configuration” to multiple “Tests”

Jump to solution

Hi DeyanChavdarov,

 

Can you give some smple of the OTA API script (maybe SQL request as well) which will add Test configuration for some set of test cases?

We use HPQC 11

 

Our use case is that we are using Test configuration to cover OS's and we want to add new Test configuration for Windows 10 for existing test cases.

 

Regards,
Dmitri

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Define one “Test configuration” to multiple “Tests”

Jump to solution

It is not complicated to do this using the OTA API. Assuming you have created a list of the tests for which you want to add the configurations, in VBScript

 

For each tst in tstlist                
      Set newConfig =  tst.TestConfigFactory.AddItem(NULL)
      newConfig.Name = "Windows 10"
      newConfig.Post
      Set newConfig = Nothing
Next
       

 

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]

View solution in original post

Highlighted
Absent Member.
Absent Member.

Re: Define one “Test configuration” to multiple “Tests”

Jump to solution

Great,

 

But now I have another problem. How to define whether this Test Configuration is already set to some of the test cases from the list?

When script find some test case from the list where Test configuration is already next error appears:

Duplicate entity: 'Test Configuration'.

 

Regards,
Dmitri

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Define one “Test configuration” to multiple “Tests”

Jump to solution

You could iterate over the Test Configurations for each test and check if the name exists.

 

Or you could do it the lazy way that I would probably use - enclose the code lines with

On Error Resume Next
...
On Error Goto 0

That will simply suppress the error in case the Configuration already exists.

 

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Highlighted
Absent Member.
Absent Member.

Re: Define one “Test configuration” to multiple “Tests”

Jump to solution

Thank you very much,

 

 

Now I have a working script (maybe someone find it useful):

 

Option Explicit 
Dim sUserName, sPassword, hpqcurl
Dim sDomain, sProject, excelfilepath, tCasesPath
Dim testConfiguration

'HPQC logon credentials 
sUserName = "username" '<-- Change me.
sPassword = "password" '<-- Change me.

'URL of the HPQC server ex. http://server/qcbin
hpqcurl = "http://server/qcbin" '<-- Change me.

'test cases path in HPQC
tCasesPath = "Subject\testfolder" '<-- Change me.


'HPQC domain and project parametrs
sDomain = "DOMAIN"   '<-- Change me.
sProject = "PROJECTNAME" '<-- Change me.

'Test Configuration
testConfiguration = "TestConfigurationToAdd" '<-- Change me.

'==========================================================================

Dim QCConnection

'Return the TDConnection object.
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
'Set QCConnection = New TDConnection


QCConnection.InitConnectionEx hpqcurl
QCConnection.Login sUserName, sPassword

If (QCConnection.LoggedIn <> True) Then
    MsgBox "QC User Authentication Failed"
    WScript.Quit
End If

QCConnection.Connect sDomain, sProject

If (QCConnection.Connected <> True) Then
    MsgBox "QC Project Failed to Connect to " & sProject
    WScript.Quit
End If

'WScript.Echo "Connection was created successfully"

'Call ExportTestCases(tCasesPath) 

Dim TreeMgr, TestTree, TestFactory, TestList
    Set TreeMgr = QCConnection.TreeManager

    'Specify the folder path in TestPlan, all the tests under that folder will be exported.
    Set TestTree = TreeMgr.NodeByPath(tCasesPath)
    Set TestFactory = TestTree.TestFactory
    Set TestList = TestFactory.NewList("") 'Get a list of all from node.

    'Specify Array to contain all nodes of subject tree.
    Dim NodesList()
    ReDim Preserve NodesList(0)
    'Assign root node of subject tree as NodeByPath node.
    NodesList(0) = TestTree.Path
    
    'Gets subnodes and return list in array NodesList
    Call GetNodesList(TestTree, NodesList)

    Dim Row, Node, TestCase, newConfig
    Row = 2
    For Each Node In NodesList
        Set TestTree = TreeMgr.NodeByPath(Node)
        Set TestFactory = TestTree.TestFactory
        Set TestList = TestFactory.NewList("") 'Get a list of all from node.

        'Iterate through all the tests.
		On Error Resume Next
        For Each TestCase In TestList

		'WScript.Echo(TestCase.Field("TS_NAME"))

		Set newConfig =  TestCase.TestConfigFactory.AddItem(NULL)
		newConfig.Name = testConfiguration
		newConfig.Post
		Set newConfig = Nothing

		
		Next
		On Error Goto 0

    Next
			
QCConnection.Disconnect
QCConnection.Logout
QCConnection.ReleaseConnection 
WScript.Echo("Done")
''
'Returns a NodesList array for all children of a given node of a tree.
'
'@param:    Node        Node in a Test Lab tree.
'
'@param:    NodesList   Array to store all children of a given node of a tree.
'
'@return:   No explicit return value.
Function GetNodesList(ByVal Node, ByRef NodesList)
    Dim i
    'Run on all children nodes
    For i = 1 To Node.Count
        Dim NewUpper
        'Add more space to dynamic array
        NewUpper = UBound(NodesList) + 1
        ReDim Preserve NodesList(NewUpper)
        
        'Add node path to array
        NodesList(NewUpper) = Node.Child(i).Path
        
        'If current node has a child then get path on child nodes too.
        If Node.Child(i).Count >= 1 Then
            Call GetNodesList(Node.Child(i), NodesList)
        End If
    Next
End Function

NOTE: if you run it on x64 bit machine please use 64bit cmd or 64bit cscript.exe

 

Regards,
Dmitri

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.