[{"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}]
前 言
做自动化测试肯定要了解就是 DDT 数据驱动测试,这样做的好处就是可以通过一组或多组数据进行灵活的测试,而不需要硬编码。
那今天我们就来讲解一下 Katalon 怎么进行测试数据读取的。
Katalon 支持的数据格式
Excel
CSV
database data
internal data
前提准备
*
创建好 Excel 文件并输入测试数据
*
通过 katalon 录制好执行的测试用例,并且把 input 里录制好的测试数据去掉
1、在 Data Files 里新建一个 Excel 格式的 testdata
重点知识:
在添加 Excel 文件后有三个设置项:
Use first row as header:勾选上会自动帮你去除掉 Excel 的 title(默认勾选)
Use relative path:如果把 Excel 放到 katalon
工程对应的文件夹下,就可以使用相对路径了,也就是勾选上之后只需要输入文件名即可,不需要绝对路径(默认不勾选)
Bind to test case as string:以字符串形式绑定到测试用例(默认勾选)
最后:一定要记得添加 Excel 之后要保存这个 datafiles 文件
2、在测试用例里面创建变量用来接收 Excel 里面的数据,默认值可以不用填写
重点知识:
一定要记得保存测试用例
3、创建一个 TestSuite 并配置一个测试用例
4、将测试用例里面的变量绑定 Excel 数据
重点知识:
一定要记得保存 Testsuite
5、运行测试用例即可看到会依据 Excel 的数据数量执行多次测试用例
到此,katalon 进行 DDT 数据驱动测试就已经实现了哦~~~
今天教的小技巧 大家学会了吗?