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

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;
}

上一篇:iOS 定位系统 知识


下一篇:Waterfall———瀑布流布局插件, 类似于 Pinterest、花瓣、发现啦。