转载来自:http://www.jianshu.com/p/b3f66be8fe45

做接口测试经常会遇到如下两种情况需要处理数据传递
- 接口间的数据依赖,A接口请求的参数需要用到B接口的返回值
- 接口请求通常要用到鉴权的接口获取Token,Token通常会跟其他接口构成一对多的关系,这种情况下我们可以把Token的接口做成一个公共的TestCase,供其他的TestCase调用
1.接口间数据传递

image.png -
解决方法
1.增加测试步骤properties用来存放A接口返回值的数据

image.png2.测试步骤properties增加变量

image.png3.增加测试步骤Property Transfer

image.png4.Property Transfer关联数据到properties

image.png5.B接口引用properties存储的A接口的返回值

image.png2.TestCase间数据传递

image.png -
解决方法
1.给TestCase-getAccessToken增加propertis保存返回值

image.png2.增加测试步骤Property Transfer并且关联到propertis

image.png3.TestCase-getProductType增加测试步骤Run TestCase调用TestCase-getAccessToken

image.png4.TestCase-getProductType引用TestCase-getAccessToken的返回值

本文介绍了解决接口测试中数据依赖问题的方法,包括接口间的数据传递和TestCase间的Token传递。通过设置测试步骤properties来存放返回值,并使用PropertyTransfer关联数据。
376

被折叠的 条评论
为什么被折叠?



