Quantcast
Channel: froglogic
Viewing all articles
Browse latest Browse all 398

Squish tip of the week: Import collection of test cases to HP’s QC / ALM

$
0
0

Did you know teams can execute, manage and analyze Squish tests and results using Squish’s QC ALM Add-on?.

Using the example below, you can also import a collection of tests to QC ALM in a single call!

Import Call and Parameters
testSuitePath = "C:\\Path\\To\\Test\\Suite\\"
objectmap = "C:\\Path\\To\\objects.map"
tcList = ["tst_contact","tst_fail"]

importListOfTestCases.py --testSuitePath %testSuitePath%
               --objectmap %objectmap% --tcList %tcList%


Script: Import List Of Test Cases
#!/usr/bin/python
# importListOfTestCases.py

import os
import subprocess
from subprocess import Popen

def importListOfTCs(testSuitePath,objectmap,tcList,qciPath, server, domain, project, user, password, path):    
    m = []
    for testCase in range(len(tcList)):
        importTC = "%(qciPath)s --testcase %(testCasePath)s --objectmap %(objectmap)s --server %(server)s --attach-shared-folder --domain %(domain)s --project %(project)s --user %(user)s --password %(password)s --path %(path)s --replace" % {"qciPath":qciPath,"testCasePath":testSuitePath + "\\" + tcList[testCase],"objectmap":objectmap,"server":server,"domain":domain,"project":project,"user":user,"password":password,"path":path}
        proc = Popen(importTC, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        err, out = proc.communicate()
        exitcode = proc.returncode
        if err:
            m.append("Error: %s" % err)
            
        if exitcode is not 0:
            m.append("Unexpected exit code: %s" % exitcode)
        
        if out:
            m.append("Test case imported: %s" % out)
    msg = "\n".join(m)
    return "\r\n----------------\r\nImport results\r\n----------------\r\n%s" % msg

# ** Use hard-code parameters below, or comment out and provide using --<parameterName> <value> when calling script
# testSuitePath = "C:\\Path\\To\\Test\\Suite\\"
# objectmap = "C:\\Path\\To\\objects.map"
# tcList = ["tst_contact","tst_fail"]
qciPath = "C:\\Path\\To\\qcimporter.exe"
server = "<server>"
domain = "<domain>"
project = "<projectName>"
user = "<user>"
password = "<password>"
path = "\"/PathForTestsInQC\""
    
conf = importListOfTCs(testSuitePath,objectmap,tcList,qciPath, server, domain, project, user, password, path)
print conf

Read more in other Squish resources below:


Viewing all articles
Browse latest Browse all 398

Trending Articles