不完美解决方案:

构件一个类,使之可以在QTP运行结束的时候被触发。这里需要用到QTP的Environment.

 Environment("TestTerminate") = [new TestTermination] 

 1 Class TestTermination
 2     Private Sub Class_Initialize
 3         ’这里写环境初始化时要做的action
 4         'call OverrideFunctions()
 5     End Sub
 6  
 7     Private Sub Class_Terminate
 8        ‘这里可以写一些QTP结束前的action
 9         'call UnRegisterFunctions()
10     End Sub
11 End Class
12 
13 function [new TestTermination]
14     set [new TestTermination] = new TestTermination
15 end function
View Code

 

Example:

 1 Class TestTermination
 2     Private Sub Class_Initialize
 3         'call OverrideFunctions()
 4     End Sub
 5  
 6     Private Sub Class_Terminate
 7         If not Frame_WorkBook is nothing Then
 8             Frame_WorkBook.save
 9             Frame_WorkBook.Close true
10             Frame_ExcelApp.Quit
11             Set Frame_WorkBook = nothing
12             Set Frame_ExcelApp = nothing
13             'RST_Test_Plan.close
14             'set RST_Test_Plan = nothing
15             'Conn_Data_Resource.Close
16             'set Conn_Data_Resource = nothing
17         End If
18         'call UnRegisterFunctions()
19     End Sub
20 End Class
21 
22 function [new TestTermination]
23     set [new TestTermination] = new TestTermination
24 end function
View Code

 

 

posted on 2014-03-06 13:20  Wandy.Ying  阅读(961)  评论(0编辑  收藏  举报