基于Lua脚本的自动化测试框架设计

发表于:2010-3-23 13:49

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

 作者:vincetest(CSDNBlog)    来源:51Testing软件测试网

  3. 测试套封装

 function WriteCaseName(sCaseName)   --标记测试用例名,写入测试报告文件 
     CurrCase = sCaseName 
     local h = io.open(reportfile,"a") 
     io.output(h) 
     local sWriteStr = "\n【" .. sCaseName .."】" .. "\n" 
     if TestEntironment == Win32 then 
         print(sWriteStr)     
     end  
     io.write(sWriteStr) 
     io.close(h) 
 end 
 function WriteCaseStep(sStep)   --标记测试步骤,写入测试报告文件 
     CurrStep = sStep 
     local h = io.open(reportfile,"a") 
     io.output(h) 
     local sWriteStr = "   |--" .. sStep .. "\n" 
     if TestEntironment == Win32 then 
         print(sWriteStr)     
     end  
     io.write(sWriteStr) 
     io.close(h) 
 end 
 function SetCurrModule(sModuleName) 
     CurrModule  = sModuleName 
     temp        = {Module = sModuleName,iRunCaseNum = 0,iOKCaseNum = 0,iNGCaseNum = 0} 
     tRunStatisticIndex = tRunStatisticIndex + 1 
     table.insert(tRunStatistic,tRunStatisticIndex,temp) 
 end 

  4. 自动化判断

 --自动比较期望结果与测试结果  
 function AssertResult(sExpects,RealResult) 
     if sExpects == RealResult then 
         return "OK" 
     else  
         return "NG" 
     end  
 
 end

  5. 测试日志

 function WriteMsg(sMsg) 
     local h = io.open(reportfile,"a") 
     io.output(h) 
     local sWriteStr = sMsg .. "\n" 
      
     if TestEntironment == Win32 then 
         print(sWriteStr)     
     end  
      
     io.write(sWriteStr) 
     io.close(h) 
 end

42/4<1234>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

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

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

沪ICP备05003035号

沪公网安备 31010102002173号