kavensyw 发表于 2010-10-28 15:52:26

QC中Filter的字符串中不能包含空格符吗?

本帖最后由 kavensyw 于 2010-10-28 16:17 编辑

Dim tdc                        'TDConnection Object
Dim tFact                'TestFactory Object
Dim TestFilter      'Filter Object
Dim TestList      'List Object

Set tdc = CreateObject("TDApiOle80.TDConnection.1")

'初始化
tdc.InitConnectionEx HostName                        '服务器地址
'登录
tdc.Login UserName,Password                              '用户名,密码
'连接
tdc.Connect Domain, Project                              '域名,项目
If tdc.Connected And tdc.LoggedIn Then
      MsgBox "Connected and Login Success!"      
End If

Set tfact = tdc.TestFactory
Set TestFilter = tfact.Filter
'使用Filter

'Filter的字符串不能有空格吗?
'在QC中把文件夹和用例名中间有空格,不能正常运行
'TestFilter.Filter("TS_NAME") = "Check Style"      
'SubjectPath ="Functional\Report\Coverage Report\All Distributors"

'在QC中把文件夹和用例名空格都去掉后,不带空格能正常运行      
TestFilter.Filter("TS_NAME") = "CheckStyle"                        '用例名
SubjectPath ="Functional\Report\CoverageReport\AllDistributors"                '用例所在文件夹路径            
TestFilter.Filter("TS_SUBJECT") = "Subject\"&SubjectPath

'列出用例,输出用例数量及ID   
Set TestList = tfact.NewList(TestFilter.Text)
If TestList.Count <> 0 Then
    MsgBoxTestList.Count                                    '
    Set theCoverTest = TestList.Item(1)
    idx = theCoverTest.ID
      MsgBox idx
End If
'断开连接
If tdc.Connected Then
      tdc.Disconnect
End If
'注销登录   
If tdc.LoggedIn Then
      tdc.Logout
End If
'释放对象
tdc.ReleaseConnection
Set tdc = Nothing

kavensyw 发表于 2010-10-28 16:11:21

本帖最后由 kavensyw 于 2010-10-28 16:15 编辑

自己解决了:
要加双引号
TestFilter.Filter("TS_NAME") = """Check Style"""
TestFilter.Filter("TS_SUBJECT") = """Subject\Functional\Report\Coverage Report\All Distributors"""

或者
TestFilter.Filter("TS_NAME") = chr(34)&"Check Style"&chr(34)
TestFilter.Filter("TS_SUBJECT") = chr(34)&"Subject\Functional\Report\Coverage Report\All Distributors"&chr(34)

archonwang 发表于 2010-10-29 11:31:21

谢了。学到了新东西。
页: [1]
查看完整版本: QC中Filter的字符串中不能包含空格符吗?