loadrunner-增加检查点(web_reg_find)

接口性能测试地址:
http://192.168.x.x:x/tionWeb/Ajax_GetStock.aspx?stockcode=600571

性能测试脚本:
Action()
{


    lr_start_transaction("01");

     web_reg_find("Text=600571",
         "Search=body",
         "SaveCount=n",
         LAST);

    web_url("Ajax_GetStock.aspx",
        "URL=http://192.168.x.x:x/tionWeb/Ajax_GetStock.aspx?stockcode=600571",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t2.inf",
        "Mode=HTTP",
        LAST);


    if(atoi(lr_eval_string("{n}"))>=1){
        
        lr_end_transaction("01",LR_PASS);
        }

    else{
        lr_end_transaction("01",LR_FAIL); 

        }
    
    return 0;
}

说明:

  •  web_reg_find()检查点函数:

 

     web_reg_find("Text=600571",
         "Search=body",
         "SaveCount=n",
         LAST);

 

  • SaveCount:统计待检查数据被检查到的次数,确定一个事务是否成功,那么至少待检查的数据至少要被检查找到一次:    
    if(atoi(lr_eval_string("{n}"))>=1){
        
        lr_end_transaction("01",LR_PASS);
        }

    else{
        lr_end_transaction("01",LR_FAIL); 

        }

    

     lr_eval_string():读取变量n的值
atoi():转化成整型

 

posted @ 2015-09-11 15:34  职场人的思考  阅读(660)  评论(0编辑  收藏  举报