打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
loadrunner脚本中参数化和返回值输出log到外部文件

  很多时候,我们在做性能测试之前,需要造数据,但是使用的这些参数化数据和生成的返回数据在后面的测试都会用的,所以我们需要在造数据过程中,将参数化的数据和生成的返回数据保存起来,以便后续测试中使用!下面就以webservice协议的脚本为例,介绍下如何来实现所需的功能!



int id,scid;
char *group;


//定义文件保存位置
char *filename = "E:\\data\\test.log";
long file_stream;
Action()
{

web_service_call( "StepName=crmOpenAcc_101",
"SOAPMethod=LenderFsoServerImplService|LenderFsoServerImplPort|crmOpenAcc",
"ResponseParam=response",
"Service=LenderFsoServerImplService",
"ExpectedResponse=SoapResult",
"Snapshot=t1438929987.inf",
BEGIN_ARGUMENTS,
"xml:crmOpenAccReqData="
"<crmOpenAccReqData>"
"<birthday>1988/09/03</birthday>"
"<certificateNo>{certificateNo}</certificateNo>"
"<certificateType>01</certificateType>"
"<city>未填写</city>"
"<county>未填写</county>"
"<crmName>adminMGMT</crmName>"
"<customerType>0</customerType>"
"<ecpMobile>15030502101</ecpMobile>"
"<email>12345@qq.com</email>"
"<emergContactPerson>紧急联系人</emergContactPerson>"
"<fsoId>12345678901234567890123456789012</fsoId>"
"<gender>1</gender>"
"<isPaperBill>0</isPaperBill>"
"<jurisdictionCity>未填写</jurisdictionCity>"
"<jurisdictionProvince>未填写</jurisdictionProvince>"
"<mobile>{mobile}</mobile>"
"<orgBizDeptId>ff8080814d744d17014e7222cff33307</orgBizDeptId>"
"<orgTeamId>ff8080814d744d17014e72243fc1330a</orgTeamId>"
"<ownerId>ff8080814d744d17014e722afbbf330f</ownerId>"
"<postAddress>未填写</postAddress>"
"<province>未填写</province>"
"<signInfo>0</signInfo>"
"<systemSourceId>MGMT</systemSourceId>"
"<tel>01083383383</tel>"
"<userFrom>pc</userFrom>"
"<userName>testcc</userName>"
"</crmOpenAccReqData>",
END_ARGUMENTS,
BEGIN_RESULT,
"return/retCode=Param_retCode",
"return/retInfo=Param_retInfo",
"return/customerId=Param_customerId",
END_RESULT,
LAST);


......略


//在回放日志中打印参数
   lr_output_message("The Param_customerId's value is %s",lr_eval_string("{Param_customerId}"));
   lr_output_message("The certificateNo's value is %s",lr_eval_string("{certificateNo}"));
   lr_output_message("The certificateNo's value is %s",lr_eval_string("{mobile}"));


   if ((file_stream = fopen(filename,"a+")) == NULL)
   {
   lr_error_message("Cannot open %s", filename);
   return -1;
   }
   lr_whoami (&id,&group,&scid);


//获取当前时间
   lr_save_datetime("%H:%M:%S",DATE_NOW + TIME_NOW,"times");
   if (id > 0)
   {


//保存需要的参数
   fprintf(file_stream," %s %s %s\n",lr_eval_string("{Param_customerId}"), lr_eval_string("{certificateNo}"),lr_eval_string("{mobile}"));
   }
   fclose(file_stream);
return 0;
}


 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
LoadRunner字符串与参数的操作及转换技巧
【竺】性能测试笔记9——判断事务是否成功的几个方法
LoadRunner常用函数
Loadrunner脚本编程(1)-大体思路
loadrunner 脚本开发
LR常用函数整理
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服