[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
传统的测试用例须要测试或者开发人员将用户的操做用代码表示出来,经过断言判断是否和预期一致,写测试用例也占用了部分时间,加上版本迭代测试用例的维护成本也较高,因而基于无埋点的需求相结合自动化测试来检测埋点,及时告警,提升准确率和代码质量,为了减小测试用例的开发维护时间,诞生了自动生成测试用例的方案,另外不由于出错而中断代码的执行。html
测试框架:
测试框架使用FAutoTest,能够测试小程序,H5,对比曾经用过的selenium,代码运行要稳定不少,wait的时间也都很稳定,对比phantom截图像素对比,能够细化测试用例的行为,基于x5内核的driver能测试微信环境,能覆盖到现业务的使用场景。python
如何自动生成测试用例?
1.首先在后台配置测试用例,具体思路小程序
获取点击位置xpath,该测试用例预期文案或者样式微信
请求接口将测试用例数据配置写入表,并提供接口拉取全部测试用例数据框架
2.配置完测试用例,python请求接口获取测试用例配置的入参(in字段),出参(out字段),in里边的字段是入参,url是点击行为所在的页面,xpath是点击的位置,out里边的字段是出参,url是预期要跳转的页面,xpath是预期页面的标记位置,带text是预期的文案,带class是预期的样式,把用户行为尽可能拆分红入参,出参可以表达的行为ide
3.python请求接口,遍历接口数据生成前缀为test_case_xxx的测试用例,自动生成测试用例而不是在一条测试用例里边执行完全部的行为,避免出错而中断代码执行。测试
生成测试报告:
1.安装HTMLTestRunnerurl
HTMLTestRunner 是 Python 标准库的 unittest 模块的一个扩展,它能够生成 HTML的 测试报告。htm
2.测试脚本中引入接口
from HTMLTestRunner import HTMLTestRunner
3.定义测试报告的路径,调用HtmlTestRunner
4.执行测试脚本,打印测试报告,生成html。
5.再次执行测试脚本,生成测试报告。
最后:啥也不是说了,就是加油!