首页 > 代码库 > loadrunner接口测试脚本

loadrunner接口测试脚本

使用get请求http,查看平均响应时间,以及TPS,code如下:

get(){	//get方式接口	//char *errorcode;	//int res;	//lr_start_transaction("get");   /* web_reg_save_param("Result",		"Notfound=error",		"LB=<result>",		"RB=<\/result>",		"Search=All",		LAST);*/	lr_start_transaction("get");	web_reg_find("Text=items","SaveCount=itemsCount",LAST);	web_url("get", 			//"URL=http://audi.autonavi.com/mapapi/poi/search-with-keyword?key=audi_live&md5=36c3bc8a2e0561fd16809e22afe83355&from=audi_mmi&language=zh-cn&keyword=zhongguancun",             //"URL=http://10.2.134.29:8008/ws/mapapi/poi/search?channel=autonavi&query_type=TQUERY&keywords=%E7%89%9B%E8%82%89%E9%9D%A2&qii=false&sign=B45FABB19203F2655BA5CD49F646222D&from=telematics-test",			"URL=https://telematics-test.autonavi.com/bmw/fts/search?OP=fts&app_id=bmwfts&app_code=gft9Hbdn7qVaI4GAC51G0qRGIVgPZ3Tf8J4Ly1Yy&q=KFC&in=39.994613,116.479143%3br=10000000&size=50&accept-language=zh-CN&accept=application/json&accept-encoding=gzip&tf=plain&user-agent=BMWcar",            "RecContentType=application/json",			LAST);	//lr_end_transaction("get", LR_AUTO);	if(atoi(lr_eval_string("{itemsCount}")) > 0){		lr_output_message("本次请求成功");		lr_end_transaction("get", LR_PASS);	}	else{		lr_error_message("本次请求失败");		lr_end_transaction("get", LR_FAIL);		return 0;	}

 

loadrunner接口测试脚本