lua软件测试自动化,基于Lua脚本的自动化测试框架设计

function AddRunStatistic(sAssertResult)

--统计测试执行情况

tRunStatistic[tRunStatisticIndex].iRunCaseNum = tRunStatistic[tRunStatisticIndex].iRunCaseNum + 1

if sAssertResult == "OK" then

tRunStatistic[tRunStatisticIndex].iOKCaseNum = tRunStatistic[tRunStatisticIndex].iOKCaseNum + 1

else

tRunStatistic[tRunStatisticIndex].iNGCaseNum = tRunStatistic[tRunStatisticIndex].iNGCaseNum + 1

--将失败的插入tRunNG

if (tRunNG[CurrNGModuleIndex]~= nil)and(tRunNG[CurrNGModuleIndex][1] == CurrModule) then  --存在Module记录

if (tRunNG[CurrNGModuleIndex] [2][CurrNGCaseIndex][1]~= nil)and(tRunNG[CurrNGModuleIndex][2] [CurrNGCaseIndex][1] == CurrCase) then --存在Case记录

--添加Step项

table.insert(tRunNG[CurrNGModuleIndex][2][CurrNGCaseIndex][2],CurrStep)

else

--增加Case项

table.insert(tRunNG[CurrNGModuleIndex][2],{CurrCase,{CurrStep}})

CurrNGCaseIndex = CurrNGCaseIndex + 1

end

else --增加Module项

table.insert(tRunNG,{CurrModule,{{CurrCase,{CurrStep}}}})

CurrNGModuleIndex = CurrNGModuleIndex + 1

CurrNGCaseIndex   = 1  --复位1

end

end

end

--统计测试用例执行情况

function GetStatistic()

WriteMsg("\nTestcase run statistic:")

WriteMsg("**********************************************************************")

WriteMsg("【ModuleName】".."          【Run】".."          【OK】".."          【NG】")

WriteMsg("----------------------------------------------------------------------")

for i = 1,table.getn(tRunStatistic) do

--打印格式

s1 = ""

for j = 1,24 - string.len(tRunStatistic[i].Module) do

s1 = s1 .." "

end

s2 = ""

for j = 1,17 - string.len(tRunStatistic[i].iRunCaseNum) do

s2 = s2 .. " "

end

s3 = ""

for j = 1,16 - string.len(tRunStatistic[i].iOKCaseNum) do

s3 = s3 .. " "

end

WriteMsg(i..":"..tRunStatistic[i].Module..s1..tRunStatistic[i].iRunCaseNum..s2..tRunStatistic[i].iOKCaseNum..s3..tRunStatistic[i].iNGCaseNum)

end

WriteMsg("**********************************************************************")

--记录执行失败用例

GetRunNGCase()

end

--记录执行失败用例

function GetRunNGCase()

WriteMsg("NG case info:")

if table.getn(tRunNG)==0 then

WriteMsg("No NG case,are you sure your case is perfect?")

end

for i = 1,table.getn(tRunNG) do

WriteMsg(tRunNG[i][1])   --Module Name

for j = 1,table.getn(tRunNG[i][2]) do

WriteMsg("  |--"..tRunNG[i][2][j][1]) --Case Name

for k = 1,table.getn(tRunNG[i][2][j][2]) do

WriteMsg("        |--"..tRunNG[i][2][j][2][k])    -- Step Name

end

end

end

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值