某游戏情义触发 自动化测试框架
这几天一直在测情义,可是手动计算实在是眼泪都算出来了。所以就想到了搭一个自动化测试的框架
#首先对8个主将位置进行重置,原理是换上同一个垃圾将这样之后换的就会顶掉之前的之前的位置就空出来了,
for t in 0..7
uri="http://luat.mjsanguo.com/api/v2/hero/team/adjust?t=DM6Co5R5q88wOSMdrmjo3zZTYzbTVHQypGEXyD3M2CUtQDl-MqQSRActbAZE6ZXX&pos=#{1+t}&id=70992&__=1389073347"
html_response = nil
open(uri) do |http|
html_response = http.read
end
sleep 2
end
###然后从excel表当中读出之前设定需要检验的武将
info[t]=worksheet1.Range("#{row[t]}#{i}").Value
###再对卡牌属性进行记录 以便之后进行计算
uri="http://luat.mjsanguo.com/api/v2/card/list?t=DM6Co5R5q88wOSMdrmjo3zZTYzbTVHQypGEXyD3M2CUtQDl-MqQSRActbAZE6ZXX&_=1386579374923"
html_response = nil
open(uri) do |http|
html_response = http.read
webs = JSON.parse html_response
for ii in 0..webs["data"].length-1
if webs["data"][ii]["name"]==info[0]
puts "输出武将属性"
puts worksheet1.Range("P#{i}").Value=webs["data"][ii]["attack"]
puts worksheet1.Range("R#{i}").Value=webs["data"][ii]["brain"]
puts worksheet1.Range("Q#{i}").Value=webs["data"][ii]["defend"]
puts worksheet1.Range("S#{i}").Value=webs["data"][ii]["blood"]
end
if webs["data"][ii]["name"]==info[11]
puts "输出武器攻击"
puts worksheet1.Range("X#{i}").Value=webs["data"][ii]["attack"]
end
if webs["data"][ii]["name"]==info[12]
puts "输出装备防御"
puts worksheet1.Range("Y#{i}").Value=webs["data"][ii]["defend"]
end
if webs["data"][ii]["name"]==info[13]
puts "输出坐骑"
puts worksheet1.Range("Z#{i}").Value=webs["data"][ii]["blood"]
end
end
end
###得到各个卡牌的id,准备换上去
puts hero[count]=worksheet2.Range("B#{tt}").Value.to_i
#更换武将
uri="http://luat.mjsanguo.com/api/v2/hero/team/adjust?t=DM6Co5R5q88wOSMdrmjo3zZTYzbTVHQypGEXyD3M2CUtQDl-MqQSRActbAZE6ZXX&pos=#{1+tt}&id=#{hero[tt]}&__=1389073347"
html_response = nil
open(uri) do |http|
html_response = http.read
end
#更换装备
uri="http://luat.mjsanguo.com//api/v2/hero/assemble?t=DM6Co5R5q88wOSMdrmjo3zZTYzbTVHQypGEXyD3M2CUtQDl-MqQSRActbAZE6ZXX&pos=1&sub=#{1+tt}&cardId=#{equip[tt]}&__=1389073484"
html_response = nil
open(uri) do |http|
html_response = http.read
end
然后再读出更换装备后的属性进行记录