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