川石教育
全国咨询热线:136-9172-9932
  1. 首页 > 资讯与干货 > 常见问题

性能测试构建阶段主要做哪些工作?

作者:川石学院 日期:2021-03-17 16:08:59 点击数:

        设计阶段完成后,进入构建阶段,主要完成设计测试用例、开发测试脚本和确定监控模型。 首先设计测试用例,本实例中设计的测试用例包括登录和订票两个功能,登录的测试用例见表 16-7

        性能测试构建阶段主要做哪些工作?(图1)

性能测试构建阶段主要做哪些工作?(图2)

        接着开发测试脚本,开发登录脚本时需要注意以下几个问题: (1)当输入订票系统的地址时,客户端会向服务器端发送一个 SessionID 值,服务器端收到 这个 SessionID 值后会返回一个 SessionID 值到客户端,而这个值是一个动态的值,所以在开发脚 本时会进行关联。

     (2)需要插入事务来获取登录所需要的时间,但需要注意的是,结束事务的状态不能直接写 为自动,结束事务的状态应该由检查的结果来确定。 (3)设置检查点,确定登录是否成功,即检查登录的用户是否显示正确。当检查点正确时, 将结束事务的状态设置为 PASS,否则设置事备的结束状态设置为 FAIL。 (4)对登录的用户名和密码进行参数化。 登录的脚本代码如下:

        Action() {  /* Registering parameter(s) from source task id 791  // {CSRule_1_UID2} = "106229.040745241ftztVfzpciDDDDDDDcHitpQDHH"  // */  //关联  web_reg_save_param("CSRule_1_UID2",  "LB=userSession value=",  "RB=>",  "Ord=1",  "RelFrameId=1.2.1",  "Search=Body",  LAST);  web_url("WebTours",  "URL=http://127.0.0.1:1080/WebTours/",  "TargetFrame=",  "Resource=0",  "RecContentType=text/html",  "Referer=",  "Snapshot=t1.inf",  "Mode=HTML",  LAST);  web_add_cookie("BAIDUID=EED4BF3C68FCA425464A7B08B3E6721B:FG=1; DOMAIN=passportso.baidu.com"); web_add_cookie("BDUSS=HZ3QTFxaVdJT2NaeVYzMUN4LVFHN2pkbGxSWGZ2fnJmblUybGhuOGtJOUJZRTlPQVFB QUFBJCQAAAAAAAAAAApBEw8VdxMLYXJpdm5odWFuZwAAAAAAAAAAAAAAAAAAAAAAAAAAAADgGoV0AAA AAOAahXQAAAAAcF1CAAAAAAAxMC42NS4yMkHTJ05B0ydOZ; DOMAIN=passportso.baidu.com");  web_add_cookie("USERID=379f52fe979c4447da48be6ab312; DOMAIN=passportso.baidu.com");  web_url("q",  "URL=http://passportso.baidu.com/checkuser/q?t=1311397506",  "TargetFrame=",

        "Resource=0",  "RecContentType=text/html",  "Referer=",  "Snapshot=t2.inf",  "Mode=HTML",  LAST);  web_add_cookie("BAIDUID=EED4BF3C68FCA425464A7B08B3E6721B:FG=1; DOMAIN=fetch. im.baidu.com");  web_add_cookie("USERID=379f52fe979c4447da48be6ab312; DOMAIN=fetch.im.baidu.com");  web_url("ihaloader",  "URL=http://fetch.im.baidu.com/ihaloader?op=msgcount&charset=gbk&callback=  WebIMHistMsg&refer=toolbar&un=arivnhuang",  "TargetFrame=",  "Resource=0",  "RecContentType=text/html",  "Referer=",  "Snapshot=t3.inf",  "Mode=HTML",  LAST);  lr_think_time(6);  //添加检查点  web_reg_find("Search=Body",  "Text=test11",  "SaveCount=regno",  LAST);  result = web_reg_find("Search=Body",  "Text=test11",  LAST);  web_submit_data("login.pl",  "Action=http://127.0.0.1:1080/WebTours/login.pl",  "Method=POST",  "TargetFrame=",  "RecContentType=text/html",  "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",  "Snapshot=t4.inf",  "Mode=HTML",  ITEMDATA,  "Name=userSession", "Value={CSRule_1_UID2}", ENDITEM,  "Name=userName", "Value={user}", ENDITEM,"Name=Password", "Value=1", ENDITEM,  "Name=JSFormSubmit", "Value=on", ENDITEM,  "Name=Login.x", "Value=53", ENDITEM,  "Name=Login.y", "Value=13", ENDITEM,  LAST);  //通过检查点来判断事务是否成功  if (atoi(lr_eval_string("{regno}"))>=1) {  lr_end_transaction("Login", LR_PASS);  }  else{  lr_end_transaction("Login", LR_FAIL);  }  web_url("SignOff Button",  "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1",  "TargetFrame=body",  "Resource=0",  "RecContentType=text/html",  "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",  "Snapshot=t5.inf",  "Mode=HTML",  LAST); return 0; } 最后开发订票脚本,此时需要注意以下几个问题: (1)对出发城市和到达城市进行参数化,出发城市和到达城市不能为同一城市。 (2)选择航班时为了更真实地模拟客户的行为,选择最便宜的航班。 (3)插入相关事务来获取订票的响应时间。 订票的脚本代码如下:

        Action() {  int i; //循环次数变量  int flagno;//标识位,最贵机票是数组中的第几个值  int min;//最贵机票  char cost[20];//当前机票的价格  char flightcost[20];  char flightnocost[20];  char flightelem[30];//航班  char flightno[30];  web_concurrent_end(NULL);  web_url("Search Flights Button", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?page=search",   "Resource=0",   "RecContentType=text/html",   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",   "Snapshot=t17.inf",   "Mode=HTTP",   LAST);  web_concurrent_start(NULL);  web_url("reservations.pl",   "URL=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome",   "Resource=0",   "RecContentType=text/html",   "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?page=search",   "Snapshot=t18.inf",   "Mode=HTTP",   LAST);  web_url("nav.pl_3",   "URL=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",   "Resource=0",   "RecContentType=text/html",   "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?page=search",   "Snapshot=t19.inf",   "Mode=HTTP",   LAST);  web_concurrent_end(NULL);  web_url("button_next.gif",   "URL=http://127.0.0.1:1080/WebTours/images/button_next.gif",   "Resource=1",   "RecContentType=image/gif",   "Referer=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome",   "Snapshot=t20.inf",   LAST);  web_concurrent_start(NULL);  web_url("in_flights.gif",   "URL=http://127.0.0.1:1080/WebTours/images/in_flights.gif",   "Resource=1",   "RecContentType=image/gif",   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",   "Snapshot=t21.inf",   LAST);  web_url("home.gif",   "URL=http://127.0.0.1:1080/WebTours/images/home.gif",  "Resource=1",   "RecContentType=image/gif",   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights",   "Snapshot=t22.inf",   LAST);  web_concurrent_end(NULL);  //创建机票价格的关联函数  web_reg_save_param( "WCSParam_Text1", "LB=center>$ ", "RB=</TD>", "Ord=All",  "IgnoreRedirections=Yes", "Search=Body", "RelFrameId=1", LAST );  //创建航班的关联函数  web_reg_save_param( "WCSParam_Text2", "LB=outboundFlight value=", "RB=;", "Ord=All",  "IgnoreRedirections=Yes", "Search=Body", "RelFrameId=1", LAST );  web_submit_data("reservations.pl_2",   "Action=http://127.0.0.1:1080/WebTours/reservations.pl",   "Method=POST",   "RecContentType=text/html",   "Referer=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome",   "Snapshot=t23.inf",   "Mode=HTTP",   ITEMDATA,   "Name=advanceDiscount", "Value=0", ENDITEM,   "Name=depart", "Value=Frankfurt", ENDITEM,   "Name=departDate", "Value=10/26/2011", ENDITEM,   "Name=arrive", "Value=Denver", ENDITEM,   "Name=returnDate", "Value=10/27/2011", ENDITEM,   "Name=numPassengers", "Value=1", ENDITEM,   "Name=seatPref", "Value=None", ENDITEM,   "Name=seatType", "Value=Coach", ENDITEM,   "Name=.cgifields", "Value=roundtrip", ENDITEM,   "Name=.cgifields", "Value=seatType", ENDITEM,   "Name=.cgifields", "Value=seatPref", ENDITEM,   "Name=findFlights.x", "Value=58", ENDITEM,   "Name=findFlights.y", "Value=5", ENDITEM,   LAST);  //初始化最贵机票,将第一个航班的机票设置为初始化的最贵机票  min = atoi(lr_eval_string("{WCSParam_Text1_1}"));  //初始化标识位,默认设置为 1  flagno = 1;  //for 循环所有机票  for(i = 2;i <= atoi(lr_eval_string("{WCSParam_Text1_count}"));i++){  sprintf(cost,"{WCSParam_Text1_%d}",i);  //比较最前航班的机票是否大于 max 的值,如果大于 max 的值,则重新对 max 赋值 if(atoi(lr_eval_string(cost)) < min){  min = atoi(lr_eval_string(cost));  lr_error_message("%d",max);  flagno = i;  }  }  sprintf(flightcost,"{WCSParam_Text1_%d}",flagno);  lr_save_string(lr_eval_string(flightcost),"flightnocost");   //通过标识位来确定航班  sprintf(flightelem,"{WCSParam_Text2_%d}",flagno);  lr_save_string(lr_eval_string(flightelem),"flightno");   web_submit_data("reservations.pl_3",   "Action=http://127.0.0.1:1080/WebTours/reservations.pl",   "Method=POST",   "RecContentType=text/html",   "Referer=http://127.0.0.1:1080/WebTours/reservations.pl",   "Snapshot=t24.inf",   "Mode=HTTP",   ITEMDATA,   "Name=outboundFlight", "Value={flightno};{flightnocost};10/26/2011", ENDITEM,   "Name=numPassengers", "Value=1", ENDITEM,   "Name=advanceDiscount", "Value=0", ENDITEM,   "Name=seatType", "Value=Coach", ENDITEM,   "Name=seatPref", "Value=None", ENDITEM,   "Name=reserveFlights.x", "Value=57", ENDITEM,   "Name=reserveFlights.y", "Value=13", ENDITEM,   LAST);  web_submit_data("reservations.pl_4",   "Action=http://127.0.0.1:1080/WebTours/reservations.pl",   "Method=POST",   "RecContentType=text/html",   "Referer=http://127.0.0.1:1080/WebTours/reservations.pl",   "Snapshot=t25.inf",   "Mode=HTTP",   ITEMDATA,   "Name=firstName", "Value=test", ENDITEM,   "Name=lastName", "Value=test", ENDITEM,   "Name=address1", "Value=", ENDITEM,   "Name=address2", "Value=", ENDITEM,   "Name=pass1", "Value=test test", ENDITEM,   "Name=creditCard", "Value=", ENDITEM,   "Name=expDate", "Value=", ENDITEM, "Name=oldCCOption", "Value=", ENDITEM,   "Name=numPassengers", "Value=1", ENDITEM,   "Name=seatType", "Value=Coach", ENDITEM,   "Name=seatPref", "Value=None", ENDITEM,   "Name=outboundFlight", "Value={flightno};{flightnocost};10/26/2011", ENDITEM,   "Name=advanceDiscount", "Value=0", ENDITEM,   "Name=returnFlight", "Value=", ENDITEM,   "Name=JSFormSubmit", "Value=off", ENDITEM,   "Name=.cgifields", "Value=saveCC", ENDITEM,   "Name=buyFlights.x", "Value=41", ENDITEM,   "Name=buyFlights.y", "Value=17", ENDITEM,   LAST);  web_url("bookanother.gif",   "URL=http://127.0.0.1:1080/WebTours/images/bookanother.gif",   "Resource=1",   "RecContentType=image/gif",   "Referer=http://127.0.0.1:1080/WebTours/reservations.pl",   "Snapshot=t26.inf",   LAST);  return 0; }最后确定监控模型,即在测试过程中需要监控哪些信息,本实例的监控模型见表 16-9。

性能测试构建阶段主要做哪些工作?(图3)


相关文章
  • 亚马逊运营成功转行软件测试,薪资13K表示很满意!2021-03-17 16:08:59
  • 西安川石的兰朋友喊你来当他的学弟学妹啦!2021-03-17 16:08:59
  • 国外的月亮也不一定比国内测试猿的年薪美~2021-03-17 16:08:59
  • 建筑工程专业朱同学成功转行为软件测试人!2021-03-17 16:08:59
  • 财务管理专业转行软件测试月薪甩会计几条街!2021-03-17 16:08:59
  • 只有技术沉淀才能成功上岸,深圳就业薪资13K!2021-03-17 16:08:59
  • 薪资11K!实现自我价值,从掌握一门IT技术开始...2021-03-17 16:08:59
  • 文科生转行软件测试照样拿下高薪15K!2021-03-17 16:08:59
  • 恭喜罗同学喜提19.5K,成功入行软件测试!2021-03-17 16:08:59
  • 毕业1年,迷茫的他最终选择转行软件测试2021-03-17 16:08:59