如果是多层架构,QTP能否退出当前测试脚本并运行下一个测试脚本(通过主驱动程序脚本)?

时间:2015-01-22 10:31:23

标签: vbscript qtp

以下是我们的3层QTP框架的设计。我的问题是

  1. 如果在Tier2或Tier3中发生错误,QTP能否退出当前测试脚本并运行下一个测试脚本(通过主驱动程序脚本)?
  2. 我在下面写的主脚本的代码是否有任何问题。主脚本执行单独的测试脚本,并将结果状态,开始时间和结束时间写入字典,然后将字典写回Excel工作表
  3. 你们看到这个设计有任何其他限制/改进吗? 请帮忙!
  4. Master Driver Script – Tier1
    
    Function Master ()
    	‘Take the contents of the excel sheet which stores the path of the test scrip        to be executed, status, start time and end time in a record set
         Do While Not oRecSet.EOF
    			dicResultSet.Add rCnt, CreateObject (“Scripting.Dictionary”)
    			For Each oField In oRecSet.Fields
    				dicResultSet (rCnt).Add oField.Name, oField.Value
    				‘Execute individual scripts
    				If oField.Name = “Path” Then
    					msQTPapp.Open oField.Value, True
                                            Set qtTestScript = msQTPapp.Test
                                            qtTestScript.Settings.Run.OnError = "NextStep"
                                            strStartTime = Now
                                            qtTestScript.Run
                                            qtTestScript.Close
                                            strEndTime = Now
    				End If
    				‘Write the status of the last run script in the dictionary object
    				If oField.Name = “Status” Then
                        dicResultSet (rCnt).Item (“Status”)=_                 qtTestScript.LastRunResults.Status
    				End If
    				‘Write the start time of the last run script in the dictionary     object
    				If oField.Name = “StartTime” Then
                        icResultSet (rCnt).Item (“StartTime”) = strStartTime
    				End If
    				‘Write the end time of the last run script in the dictionary object
    				If oField.Name = “EndTime” Then
                        dicResultSet (rCnt).Item (“EndTime”) = strEndTime
                        qtTestScript = Nothing
    				End If
    			Next
    			oRecSet.MoveNext
    			rCnt= rCnt+1
    		Loop
            'Write the status, start time and end time of the individual test scripts in an excel sheet 
            'Close the rec set and connection
    End Function 
    
    Test Script: Action – Tier2
    
    ‘Associate the individual test script with Environmental files, OR and other function library
    Function Test1 ()
    	‘Call L1 from Function lib
    	‘Call L2 from Function lib
    End Function
    
    Function Library– Tier3
    
    Function L1()
    	‘Actual task is getting done here
    End Function
    .
    .
    Function Ln()
    	‘Actual task is getting done here
    End Function

1 个答案:

答案 0 :(得分:0)

我将关注问题1.如果您想问其他问题,请提出两个问题。然而,我担心,由于过于宽泛或主要以意见为基础,它们将被关闭。

简短回答:

通过AOM调用的测试可以退出,例如使用ExitTest,而调用者确实可以继续执行另一个测试。这与完全没有明确退出的测试完全相同,只是执行正常的执行流程,然后优雅地终止。

即使测试由于运行时错误而中止,调用者脚本也会重新获得控制权,并且可以像成功运行测试后一样继续。