QTP的报告管理扩展框架 - ReporterManager

发表于:2008-1-30 14:09

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:陈能技    来源:陈能技的博客

#
QTP

        ReporterManager是一个QTP的报告管理扩展框架,目前最新版本是0.9.2,可到www.AdvancedQTP.com下载

        支持好几种方式的报告,例如:弹出消息框的报告方式、Excel表格样式、Windows事件日志数据库报告、样式文本、屏幕截屏,还有QTP自身的报告,最新版本的还支持XML格式报告。

        下面是一个简单的使用ReporterManager的代码:

Call oReporterManager.StartEngine("Text", "Log", "") '启动一个Text类型的日志报告

Call oReporterManager.Report ("Pass", "Step 1" ,"Window Should Open" ,"All OK", "No Details")  '把事件记录到文件中

   具体的使用方法尚未深入尝试,不过看它附带的Demo感觉挺容易使用的,并且很简单的几行调用代码就能得到很漂亮的Excel报告:

 

Test Results

 

 

 

 

Test Date:

2008-1-27

 

Test Start Time:

8:58:26 PM

 

Test End Time:

8:58:46 PM

 

Test Duration:

0:00:20

 

No Of Testcases:

1

 

Total No Of Test Steps:

3

 

 

 

 

TestCase Name

Status

No Of Steps

Action1 > Iteration (Test-Action) = 1-1

Fail

3

 

 

 

 

 

 

 

 

STEP NAME

STATUS

EXPECTED RESULT

ACTUAL RESULT

ERROR MESSAGE

 

Action1 > Iteration (Test-Action) = 1-1

Step 1

Pass

Window Should Open

All OK

No Details

Step 2

Warning

Window Should Open

It Didn't

Some Details

Step 3

Fail

Window Should Open

App. Crashed

Bla Bla Bla

 

   下面是它附带的Demo脚本代码,可以清楚知道如何使用各种格式的报告引擎:

'''<summary>This is a demo QTP test, that showcases some of the ReporterManager abilities</summary>

'''<datecreated>01/09/2007</datecreated>

'''<version>0.9</version>

 

Option Explicit

''Written by Yaron Assa, 1/9/07. Project home at www.AdvancedQTP.com

 

'Here's an extensive yet effective reporting framework example:

 

'Add QTP native reporter to the party. This way we wont need 2 reporting commands - one to ReporterManager, and one to the QTP result log

Call oReporterManager.StartEngine("QTP", "QTP", "")

 

'Set up a complete backup log - the basics

Call oReporterManager.StartEngine("Text", "Backup", "File>C:\Logs\QTPLog.txt")

'Make sure to copy the demo MDB database to c:\QTP Log.mdb

Call oReporterManager.StartEngine("DB", "DB Backup", "CreateNew>True")

 

'Set up statistics log - with it we can later produce the step pass/fail ratio with a click of a button

Call oReporterManager.StartEngine("Text", "Stats", "File>C:\Logs\Statistics.CSV|BodyTemplate>""%Status%, %StepName%, %Expected%, %Actual%, %Details%"" & vbcrlf|NewTestCaseTemplate>""General, Switched TestCase, , , %TestCaseName%"" & vbcrlf")

 

'Set up dedicated performence log - we can load it to excel and imiddiatly extract the time-step differences between relevant steps

Call oReporterManager.StartEngine("Text", "Performance", "File>C:\Logs\Performance.CSV|BodyTemplate>""%Time%, %StepName%"" & vbcrlf|NewTestCaseTemplate>"" "" ")

 

'Set up a top view excel log, so we'll have something pretty to send to management

Call oReporterManager.StartEngine("Excel", "TopView", "File>C:\Logs\TopView.xls")

 

'Set up a dedicated error & warnning logs

 Call oReporterManager.StartEngine("Text", "Errors", "File>C:\Logs\Errors.txt|BodyTemplate>""%Time%, %Status%, %StepName%, %Expected%, %Actual%"" & vbcrlf")

 Call oReporterManager.StartEngine("Winlog", "Win Errors", "ShowAs>QTP Errors")

 Call oReporterManager.StartEngine("ScreenCapture", "Error Captures", "Path>C:\Logs\|Prefix>Error -")

 

'Set up the filter for errors

      Call oReporterManager.AddFilter("RegEx", "Errors>Win Errors>Error Captures", "Pattern>Fail|WhatToSearch>Status")

 

'Set up a user popup that alerts whoever's watching that an error has occured - enable major time saves as a script can be stopped imidiatly

 Call oReporterManager.StartEngine("User", "Errors Pop Up", "Timer>2")

      Call oReporterManager.AddFilter("RegEx", "Errors Pop Up", "Pattern>Fail|WhatToSearch>Status")

 

 'Test the logs :

Call oReporterManager.Report ("Pass", "Step 1" ,"Window Should Open" ,"All OK", "No Details")

Call oReporterManager.Report ("Warning", "Step 2" ,"Window Should Open" ,"It Didn't", "Some Details")

Call oReporterManager.Report ("Fail", "Step 3" ,"Window Should Open" ,"App. Crashed", "Bla Bla Bla")

 

 

 另外,ReporterManager的几个VBS代码文件也值得深入学习和研究。

《2023软件测试行业现状调查报告》独家发布~

精彩评论

  • three116
    2008-1-31 10:32:14

    我在国外网站上看到过
    的确不错

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号