code for QTP and ALM
'==========================================================================
' Name: connectALM
' Summary: connect to ALM
' Parameters:
' QCServer,QCUserName, QCPassword, QCDomain, QCProject: QC and user information
' Outputs:
' True or False
'==========================================================================
Function connectALM(QCServer,QCUserName, QCPassword, QCDomain, QCProject)
Set TDConnection = CreateObject("TDApiOle80.TDConnection")
With TDConnection
'Create a connection with the QC Server
.InitConnectionEx QCServer
'Login to QC
.Login QCUserName, QCPassword
'Connect to QC Project
.Connect QCDomain, QCProject
End With
If not isnull(TDConnection) Then
Reporter.ReportEvent micPass,"Connect to ALM", "Connected successfully."
connectALM = True
Else
Reporter.ReportEvent micFail,"Connect to ALM", "Connected failed."
connectALM = null
End If
End Function
'==========================================================================
' Name: disconnectALM
' Summary: disconnect ALM, release object
' Parameters:
' TDConnection:the object connecting ALM
' Outputs: none
'==========================================================================
Function disconnectALM(TDConnection)
TDConnection.DisconnectProject
TDConnection.ReleaseConnection
Set TDConnection = Nothing
End Function
'==========================================================================
' Name: checkTestSet
' Summary: check test set exist or not
' Parameters:
' TDConnection:the object connecting ALM
' QCTestSetPath, QCTestSetName: test set information
' Outputs:
' True or False
'==========================================================================
Function checkTestSet(TDConnection,QCTestSetPath, QCTestSetName)
Set TSTreeManager = TDConnection.TestSetTreeManager
'Return the test set tree node from the specified tree path
Set TSFolder = TSTreeManager.NodeByPath(QCTestSetPath)
'Returns the list of test sets contained in the folder that match the specified pattern.
Set TSList = TSFolder.FindTestSets(QCTestSetName)
If TSList.Count = 0 Then
Reporter.ReportEvent micFail,"Mark status in ALM", "No TestSet in the."& QCTestSetPath
checkTestSet = False
Else
isFound = False
For Each TestSet in TSList
If LCase(TestSet.Name) = LCase(QCTestSetName) Then
isFound = True
checkTestSet = True
Exit For
End If
Next
'if QCTestSetName was not found then exit.
If not isFound Then
Reporter.ReportEvent micFail,"Mark status in ALM", "TestSet "& QCTestSetName & " was not found."
checkTestSet = False
End If
End If
End Function
'==========================================================================
' Name: markCaseStatusonALM
' Summary: according to array of case name, mark corresponding status in the ALM
' Parameters:
' TDConnection:the object connecting ALM
' QCTestSetPath, QCTestSetName: test set information
' Outputs: none
'==========================================================================
Function markCaseStatusonALM(TDConnection,QCTestSetPath, QCTestSetName, arrCaseName, arrCaseStatus)
blnExist = checkTestSet(TDConnection,QCTestSetPath, QCTestSetName)
Set TSTreeManager = TDConnection.TestSetTreeManager
If blnExist Then
'This enables database to update immediately when the field value changes
TestSet.AutoPost = True
'TSTestFactory manages test instances (TSTest objects) in a test set
Set TSTestFactory = TestSet.TSTestFactory
'TSTestFactory.NewList("") creates a list of objects according to the specified filter
For Each qtTest in TSTestFactory.NewList("")
'Change test status to N/A
'We do this to ensure all tests have 'not run' before starting execution
'If the execution errors out, we can keep track of the tests that were not run
qtTest.Field("TC_STATUS") = "N/A"
qtTest.Post
Next
'mark status according to input array
intCaseNumber = Ubound(arrCaseName)
'Get each case from array and find the test name from ALM
For i = 0 To intCaseNumber
For Each qtTest in TSTestFactory.NewList("")
strNameinALM = trim(qtTest.name)
'Remove [x] from test name
strNameinALM = mid(strNameinALM,4)
If Lcase(trim(strNameinALM)) = Lcase(trim(arrCaseName(i))) Then
qtTest.Field("TC_STATUS") = arrCaseStatus(i)
qtTest.Post
Exit For
End If
Next
Next
End If
End Function
'==========================================================================
' Name: addAttachmentOnQC
' Summary: according to array of case name, mark corresponding status in the ALM
' Parameters:
' TDConnection:the object connecting ALM
' QCTestSetPath, QCTestSetName: test set information
' arrOutputXMLFilePath, arrInputXMLFilePath, arrCaseName: array stored case and requst/response xml file name
' Outputs: none
'==========================================================================
Function addAttachmentOnQC(TDConnection, QCTestSetPath, QCTestSetName, arrOutputXMLFilePath, arrInputXMLFilePath, arrCaseName)
blnExist = checkTestSet(TDConnection,QCTestSetPath, QCTestSetName)
Set TSTreeManager = TDConnection.TestSetTreeManager
If blnExist Then
'This enables database to update immediately when the field value changes
TestSet.AutoPost = True
'TSTestFactory manages test instances (TSTest objects) in a test set
Set TSTestFactory = TestSet.TSTestFactory
AddAttachmentOnQC = False
intCaseNumber = Ubound(arrCaseName)
Set fso = createobject("scripting.filesystemobject")
'Get each case from array and find the test name from ALM
For i = 0 To intCaseNumber
For Each qtTest in TSTestFactory.NewList("")
strNameinALM = trim(qtTest.name)
'Remove [x] from test name
strNameinALM = mid(strNameinALM,4)
If Lcase(trim(strNameinALM)) = Lcase(trim(arrCaseName(i))) Then
strOutputXMLFilePath = Environment("TestDir")&"\OutputXML\"&arrOutputXMLFilePath(i)
strInputXMLFilePath = Environment("TestDir")&"\InputXML\"&arrInputXMLFilePath(i)
Set AttachmentFactory = qtTest.Attachments
Set Attachment = AttachmentFactory.AddItem(Null)
If fso.FileExists(strOutputXMLFilePath) Then
Attachment.FileName = strOutputXMLFilePath
Attachment.Type = 1
Attachment.Post
End If
If fso.FileExists(strInputXMLFilePath) Then
Attachment.FileName = strInputXMLFilePath
Attachment.Type = 1
Attachment.Post
End If
Attachment.Refresh
Exit For
End If
Next
Next
End if
End Function
code for QTP and ALM的更多相关文章
- QTP Test ,VAPI-XP Test,LR Test 和ALM 集成远程分布式执行遇到的“access is denied ” “unspecified error”问题
大家都知道QTP与ALM (QC的升级版)集成是最好的一个分布式执行的结合.因为毕竟QTP是一个商业软件,HP当然不会让你去跟其他的open source的工具去集成,要不他到哪里去挣钱. 有时候服务 ...
- Test Android with QTP
by Yaron Assa I have recently come across a plug-in to QTP that enables to automate tests on Android ...
- QTP Code Segment
Dim WshShellset WshShell = CreateObject("WScript.Shell")WshShell.SendKeys "{DOWN}&quo ...
- 自动化测试工具QTP和SilkTest横向PK(转)
转自:http://www.uml.org.cn/Test/201405212.asp?artid=1686 众所周知,自动化测试工具曾几何时三足鼎立,Mercury QTP/WinRunner系.I ...
- QTP 场景恢复– 函数调用
创建自动化测试是为了实现无人值守下运行,但也给开发人员带来一些问题.假如你离开办公室前启动测试,想要让它通宵运行.然而,由于不可预见的错误,您的测试会在某一点停止,中断了测试结果.因此QTP中引入场景 ...
- ALM/QC OTA Field in Database(查询ALM数据库的字段)
在使用ALM的OTA接口编写脚本的时候,通常会需要知道各个选项在数据库中对应的字段,才能通过脚本读取或写入数据.比如要获取test case的step内容,要在测试结束时将测试实际结果写回test s ...
- QTP脚本汇总比较有价值
1.Object Spy的Tips Hold the CTRL key to change the window focus or perform other mouse operations 2. ...
- 分享自己针对Automation做的两个成熟的框架(QTP 和Selenium)
自己在google code中开源了自己一直以来做的两个自动化的框架,一个是针对QTP的一个是针对Selenium的,显而易见,一个是商业的UI automation工具,一个是开源的自动化工具. 只 ...
- UI Automation的两个成熟的框架(QTP 和Selenium)
自己在google code中开源了自己一直以来做的两个自动化的框架,一个是针对QTP的一个是针对Selenium的,显而易见,一个是商业的UI automation工具,一个是开源的自动化工具. 只 ...
随机推荐
- dp(最长升序列)
http://poj.org/problem?id=2533 题意:给你n(1-1000)个数,求这n个数的最长升序列. 题解:dp[i]表示以第i个数结尾的最长升序列. #include & ...
- P4132 [BJOI2012]算不出的等式
传送门 看到这个式子就感觉很有意思 左边就是求一次函数 $y=\left \lfloor \frac{q}{p} \right \rfloor x$ 在 $x \in [0,(p-1)/2]$ 时函数 ...
- centos7中mysql不能输入中文问题的解决
首先在数据库里面输入 mysql> show variables like'%char%' -> ; +--------------------------------------+--- ...
- 谁动了我的内存:php内存泄露,系统缓存消耗? 转摘:http://blog.csdn.net/tao_627/article/details/9532497
http://www.laruence.com/2011/03/04/1894.html 前言:持续我一贯的标题党作风,说说例子解决方案,没有深入探讨. 情景:线上图片服务压缩的图片品质(100),缩 ...
- JVM(1)之 JAVA栈
开发十年,就只剩下这套架构体系了! >>> 若想使自己编写的Java程序高效运行,以及进行正确.高效的异常诊断,JVM是不得不谈的一个话题.本"JVM进阶"专 ...
- SharePoint创建web应用程序,提示密码不正确
使用版本SharePoint2010: $username="domain\username"$newpassword="xxxxxxxx"stsadm -o ...
- 解决图片插入word文档后清晰度降低的问题
解决图片插入word文档后清晰度降低的问题 在默认情况下,word程序会自动压缩插入word文档中的图片以减小整个word文档的.当我们需要插入word文档中的图片保持原始清晰度时,可以通过设置wor ...
- new和malloc申请内存失败后的处理
1.c++ 标准 new 失败是抛出异常的,Visual C++ 6.0中返回一个NULL指针. 使用new(std::nothrow)可以保证失败时返回NULL; 因此完全可以 #define ne ...
- C++ KMP文本匹配
代码如下: 环境为VC #include <iostream> #include <algorithm> #include <string> #include &l ...
- 英语单词delimiter
delimiter 来源——命令参数 [root@centos7 ~]# cat /good/passwd root:x:::root:/root:/bin/bash bin:x:::bin:/bin ...