ruby+watir生成测试报告

2012-03-27  潘文杰 


# Load classes require 'rubygems' require 'watir' # The main test begin # Create the new report r = CLReport.new() testReport = r.createReport('C:\\testlocation\\reports\\ExampleScript') # Start browser browser = Watir::IE.new browser.goto('http://www.blabla.com') # --- START TEST --- # Do a check and report the result if (1 > 0) r.addtoReport(testReport, 'Check if 1 is bigger than 0', 'PASSED', '1 is indeed bigger than 0') else r.addtoReport(testReport, 'Check if 1 is bigger than 0', 'FAILED', '1 is NOT bigger than 0!') end # Do another check and report the result if (2 > 1) r.addtoReport(testReport, 'Check if 2 is bigger than 1', 'PASSED', '2 is indeed bigger than 1') else r.addtoReport(testReport, 'Check if 2 is bigger than 1', 'FAILED', '2 is NOT bigger than 1!') end # --- END TEST --- # Close browser browser.close # Finish the report r.finishReport(testReport) rescue # Send crash info to report r.addtoReport(testReport, 'Test crashed with reason '+$!, 'FAILED', 'Test crashed!') # Finish the report r.finishReport(testReport) end


380°/3803 人阅读/0 条评论 发表评论

登录 后发表评论