香蕉云编原创发布日期:2025-03-01
Yunedit-post的后置处理可以编写sql语句清理测试过程产生的垃圾数据,可以使用response或全局变量/组变量中的变量值动态编写sql语句。
这个对于单元测试、自动化测试的可重复测试非常重要,因为接口测试肯定是有可能产生垃圾数据的,假如没有数据的清除机制,测试就无法完成一个闭环,因此后置处理非常重要。
对于是字符串格式的变量,不需要将变量写在引号''里面,会自动使用字符串代替掉。
1、接口返回变量的使用方法:
update testpost set token=${response.data.token} where id=1;
2、全局变量的使用方法:
update testpost set token=${global.value.abc} where id=1;
3、组变量的使用方法:
update testpost set token=${group.value.abc} where id=1;