探索测试之路。。。

发布新日志

  • 我对ajax协议和web协议的理解

    2009-12-08 11:10:52

    背景:
    一个.Net2003下的erp项目,web项目,
    1.登陆按钮是ajax方法,
    2.采购入库单来说,保存的时候是ajax方法保存,
    录制过程:
    登陆,入库单列表,入库单新增,保存。

    一开始用的web协议录制,回发的时候就报错,调试后发现登陆的时候,将session初始化事件放在了前台执行,也就是ajax方法。
    于是修改程序源代码,将错误屏蔽过去,强行以web协议录制完成,
    回发,没有报错,执行成功,但是数据库里面没有产生数据。继续跟踪,发现时保存的时候用到的ajax方法,web协议录制的脚本没有执行该保存方法,这估计就是协议选择不对的问题。

    改成ajax协议录制,从登陆,到入库单列表,新增,保存下来。
    登陆很成功,不需要修改代码,很好的执行了ajax方法。
    然后新增录制,在过程中因为数据录入很多用到了弹出窗口形式选择数据,这些弹出窗口返回数据用到的是JavaScript脚本,不是ajax方法,所以数据录制不下来,只有使用web_edit_field方法,将这些数据赋值进去。
    然后保存,数据保存成功,检查数据库,每次回发执行都会产生一条压力数据。

    所以我的理解,ajax执行是前台调用后台的方法执行,web协议录制的时候,不会录制下来,所以,像ajax的方法,一定要用ajax协议,否则是产生不了压力数据的。

  • lr还能这样调试

    2009-12-07 16:58:28

    这段时间在做一个。net项目下的测试

    当时。net2003正好处于调试状态,我执行lr回放的时候,竟然进入到了。net里面的调试点,并能在。net里面执行调试,呵呵,真是神奇了,发现这样调试起来还真是方便的,对于回放出错的地方很容易就能找到原因,方便脚本和代码修改。

  • each occurrence问题

    2007-09-14 15:33:47

    关于file类型里面的Update value on设置里面的Each occurrence问题描述:
    之前做了一个测试,参数化了一个登陆用户名,file类型,数据里面有两个用户,然后我想知道在controller里面是否正确按照参数话的用户执行了,设计了2个用户登陆的场景,想将每次登陆的用户写到一个txt文件里面来观察是否执行了
    比如定义了一个登陆用户参数:
    "Name=username", "Value={NewParam}", ENDITEM,
    再定义文件操作:
    int MyFile;
    char Name[10]="";
    strcat(Name,lr_eval_string("{NewParam}"));
    MyFile = fopen("c:\\test.txt","w");
    fprintf(MyFile,"%s",Name);
    fclose(MyFile);
    对于"Name=username", "Value={NewParam}", ENDITEM,里面的参数Update value on的设置,一开始设置为Each iteration,在controller里面运行时设置为一次迭代,结果test.txt文件里面只写了一个用户;设置了两次迭代,test.txt里面才写了两个用户;
    当设置为Each occurrence的时候,会发现test.txt里面是写了一个用户,但是顺序是和登陆的用户顺序相反,看了说明,才知道Each occurrence的含义是指当每次出现参数的时候,提取数据表中的下一个值,第一次参数出现的时候显示的是a用户,到了第二个参数的时候,那么就取下一个参数b了,这个时候,写入test.txt的就是用户b了,注意注意;

  • lr参数赋值

    2007-09-14 09:02:30

    定义:
    char Name[10]="";
    char Password[10]="";
    参数化:
    "Name=username", "Value={NewParam}", ENDITEM,
    "Name=password", "Value={NewParam_1}", ENDITEM,
    赋值:
    strcpy(Name,lr_eval_string("{NewParam}"));
    strcpy(Password,lr_eval_string("{NewParam_1}"));
    输出:
    lr_output_message("%s,%s",Name,Password);

    要点:
    strcpy函数和lr_eval_string函数的应用;

  • lr里面file函数应用试题+答案

    2007-09-05 11:19:03

    Exercise :

    Copy the following names into a text file and save it as c:\temp\data.txt

    BlackDog

    RockandRoll

    TheBattleofEvermore

    StairwaytoHeaven

    MistyMountainHop

    Write a program to read these names and print them into a new file c:\temp\data2.txt, each name twice. data2.txt should look like this:

    BlackDog

    BlackDog

    RockandRoll

    RockandRoll

    TheBattleofEvermore

    TheBattleofEvermore

    StairwaytoHeaven

    StairwaytoHeaven

    MistyMountainHop

    MistyMountainHop

     

    答案:

    Action17()
    {
     int MyFile,MyFile1;
     char test1[500],test2[500];
     char File[15]="c:\\data.txt";
     MyFile = fopen(File,"r");
        MyFile1 = fopen("c:\\data1.txt","w");
     while(feof(MyFile)==0)
     {
      fscanf(MyFile,"%s",test1);
      strcat(test2,test1);
      strcat(test2,"\n");
      strcat(test2,test1);
      strcat(test2,"\n");
     }
        fprintf(MyFile1,"%s",test2);
     fclose(MyFile);
     fclose(MyFile1);
     return 0;
    }

    呵呵,感觉不是最优化的方法;

  • lr习题+答案-Exercise 3.2

    2007-08-29 14:16:22

    Exercise 3.2

     

    a)      You invest  $10,000 in a special account that pays 10% interest at the end of each year on the beginning balance of the year. You decide to take your investment out as soon as it doubles. Write a program that will print out the year, beginning balance, interest gained for the year and the ending balance for the year. This program should stop as soon as the ending balance reaches $20,000. All dollar amounts should be printed to a precision of 2 decimals.

    Here is what a sample output might look like:

     

    Virtual User scrīpt started

    Running Vuser...

    Starting iteration 1.

    Actions.c(18):Year = 1, Beginning Balance = 10000.00, Interest = 1000.00, Ending Balance = 11000.00

    Actions.c(18):Year = 2, Beginning Balance = 11000.00, Interest = 1100.00, Ending Balance = 12100.00

    Actions.c(18):Year = 3, Beginning Balance = 12100.00, Interest = 1210.00, Ending Balance = 13310.00

    Actions.c(18):Year = 4, Beginning Balance = 13310.00, Interest = 1331.00, Ending Balance = 14641.00

    Actions.c(18):Year = 5, Beginning Balance = 14641.00, Interest = 1464.10, Ending Balance = 16105.10

    Actions.c(18):Year = 6, Beginning Balance = 16105.10, Interest = 1610.51, Ending Balance = 17715.61

    Actions.c(18):Year = 7, Beginning Balance = 17715.61, Interest = 1771.56, Ending Balance = 19487.17

    Actions.c(18):Year = 8, Beginning Balance = 19487.17, Interest = 1948.72, Ending Balance = 21435.89

    Ending iteration 1.

    Ending Vuser...

     

     

    My Answer:

    Action8()
    {
     int Year=1;
     float Interest = 0.1;
     float BeginningBalance = 10000;
     float EndingBalance = 0;
     while (EndingBalance<20000)
     {
      EndingBalance = BeginningBalance*0.1+BeginningBalance;
      BeginningBalance = EndingBalance;
      lr_output_message("Year=%d,Beginning Balance=%.2f,Interest=%.2f,Ending Balance=%.2f",Year,BeginningBalance,EndingBalance*Interest,EndingBalance);
      Year++;
     }
     return 0;
    }

  • 关于lr中exit(-1)和return 0的区别

    2007-08-29 11:15:30

    exit(-1):从当前action里面exit(-1)所在行,当前迭代里面直接退出来,终止运行;

    return 0:忽略当前action里面return 0后面的脚本,直接运行下一个action,以及下一个迭代;

    比如做了个测试:

    Action6()
    {
     int count = 0;
     if (count ==0)
      {
       lr_output_message("%d",count);
       exit(-1);
      }
       lr_output_message("test!"); 
    }
    运行的时候,程序在第一次迭代里面,Action6.c(6): 0执行到这句就终止了;

    Action6()
    {
     int count = 0;
     if (count ==0)
      {
       lr_output_message("%d",count);
       return 0;
      }
       lr_output_message("test!"); 
    }
    运行的时候,程序在第一次迭代里面,Action6.c(6): 0执行到这句,然后跳到下一个action,下一个迭代;

  • loadrunner并发用户思考-1

    2007-06-19 16:08:09

    对于只需要测试一个单笔业务的最大并发用户,比如登录事件,一张报表测试事件,可以进行录制脚本后,设计设计事务,集合点,然后到controller里面进行场景执行:

    场景设置:
    Initialize all Vusers before Run 勾选
    Ramp Up:Load all Vusers simultaneously;
    Duration:Run until completion;
    Scenario-Rendezvous-Policy:Realse when 100% of all Vusers arrive at therendezvous;
    为了考虑真实性,可以加入进行虚拟ip执行;
    最后:进行结果分析,查看执行情况,是否成功;
    那么保证该业务执行成功的Vusers数字就是最大并发用户数,那么这个最佳并发用户数的判断就要通过事务响应时间图进行分析了;

Open Toolbar