• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    軟件測試中LoadRunner函數中的幾個陷阱

    發布: 2010-3-04 08:56 | 作者: 網絡轉載 | 來源: 領測軟件測試網 | 查看: 196次 | 進入軟件測試論壇討論

    領測軟件測試網

    軟件測試LoadRunner函數中的幾個陷阱

    1、atof

      在loadrunner中如果直接用

      float f;

      f=atof("123.00");

      lr_output_message("%f",f);

      輸出的結果會是1244128.00,根本不是我們想要的。

      因為float,double型在不同的平臺下長度不一樣,所以在loadrunner中調用atof需要顯式的聲明這個函數。

      如下:

      doubleatof (const char *string);

      float f;

      f=atof("123.00");

      lr_output_message("%.2f",f);

      這樣就能輸出結果:123.00。

      其實,在LR關于atof的幫助文檔描述中有提到這點,要求使用這個函數前“must be explicitly declared in Vugen scripts. ”,同樣的要求也出現在atol函數的描述中。

      2、lr.save_string

      在LoadRunner中,使用.NET VUser時可以使用lr.save_string來存入一個變量,但是其使用方法卻與通常使用的lr_save_string有區別,不小心的話容易“中招”。

      C語言的lr_save_string的定義如下:

      int lr_save_string (const char *param_value, const char *param_name);

      注意:參數值在前面,參數名在后面

      而.NET VUser的lr.save_string的參數使用恰好相反,參數名在前面,參數值應該放到后面。

      但是LR的幫助文檔并沒有關于lr.save_string的定義,如果在腳本中選中“lr.save_string”,然后按F1,則直接蹦到lr_save_string的定義描述中,極容易誤導人!

      3、ftp_put

      ftp_put 是LoadRunner中的FTP函數,用于上傳文件到FTP服務器。定義如下:

      int ftp_put ( char *transaction, LAST);

      查看LR的幫助文檔可獲得如下例子:

      // Send the file "ftp_file.txt" to the for_jon directory.

      ftp_put("Ftp_Put",

      "PATH=f:/ftp_file.txt", "TARGET_PATH=/pub/for_jon", "MODE=ASCII",

      ENDITEM ,

      LAST);

      當你興匆匆地以為拿過來修改一下就可以用了的時候,LR卻提示如下錯誤:

      Starting action Action.

      globals.h(101): Warning message:PATH=D:/ftp.txt is not ftp_put valid option

      globals.h(101): Debug message:Putting file test.txt in /Qdownload/test.txt, passive mode set to 0

      globals.h(101): Error -86026:Failed to open D:\LoadRunner\LRProject\lr_FTP1\test.txt for reading.

      globals.h(101): Error -86027:Failed to put data: 226 Transfer complete

      Abort was called from an action.

      提示錯誤是文件不能讀,但是文件明明就不在錯誤所提示的D:\LoadRunner\LRProject\lr_FTP1\test.txt 中,而是在D:/ftp.txt。

      后來看到錯誤提示之前的一個Warning寫道PATH=D:/ftp.txt is not ftp_put valid option,難道錯誤是這里引起的?查看幫助文檔關于item_list的描述可知:

      item_list

      A list of all the items for this function. Enclose all entries with quotes.

      SOURCE_PATH: The file to upload to the FTP server.

      OR

      MSOURCE_PATH - Like SOURCE_PATH, but using wildcards to specify multiple files. If wildcards are not specified, all the files in the MSOURCE_PATH are uploaded.

      TARGET_PATH (optional) - the path and filename in which to place the file.

      if (M)SOURCE_PATH is specified, but TARGET_PATH is not specified, the file is stored in the root directory of the FTP server, with the original file name.

      MODE (optional) - Retrieval mode ASCII or BINARY (default).

      PASSIVE (optional) - Sets the communication protocol to Passive Mode FTP. To enable, pass "PASSIVE=TRUE".

      ENDITEM - Marks the end of the list. (no quotes)

      原來是SOURCE_PATH而不是例子所說的PATH,好吧,等你改成SOURCE_PATH后,如下所示:

      // Send the file "ftp_file.txt" to the for_jon directory.

      ftp_put("Ftp_Put",

      "SOURCE_PATH=f:/ftp_file.txt", "TARGET_PATH=/pub/for_jon", "MODE=ASCII",

      ENDITEM ,

      LAST);

      興匆匆地以為就行了,一運行又報錯:

      globals.h(101): Error -86025:Put failed; 550 /pub/for_jon: Not a regular file

      原來這次是TARGET_PATH的問題,再看LR的幫助文檔:

      TARGET_PATH (optional) - the path and filename in which to place the file.

      if (M)SOURCE_PATH is specified, but TARGET_PATH is not specified, the file is stored in the root directory of the FTP server, with the original file name.

      原來TARGET_PATH要包含文件名,因此改成:

      // Send the file "ftp_file.txt" to the for_jon directory.

      ftp_put("Ftp_Put",

      "SOURCE_PATH=f:/ftp_file.txt", "TARGET_PATH=/pub/for_jon/ftp_file.txt", "MODE=ASCII",

      ENDITEM ,

      LAST);

      這次終于行了。

      同樣的,在ftp_put_ex函數中也有類似的錯誤:

      In the following example, the ftp_get_ex function gets the file ftp_file.txt from the FTP server.

      // Send the file "ftp_file.txt" to the for_jon directory.

      ftp_put_ex(&ftp, "Ftp_Put",

      "PATH=f:/ftp_file.txt", "TARGET_PATH=/pub/for_jon", "MODE=ASCII",

      ENDITEM,

      LAST);

      而且例子代碼寫的是“ftp_put_ex”, 描述例子時卻說的是“ftp_get_ex”。

      LR是非常優秀的性能測試工具,但是如果幫助文檔中類似這樣的錯誤比較多的話,對初學者而言就又多了一道學習的門檻:鑒別聯機幫助信息的真偽的能力。

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    TAG: loadrunner LoadRunner Loadrunner loadRunner 函數 軟件測試 陷阱


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>