Several traps in the LoadRunner function in software testing 1, atof in LoadRunner if the direct use of float F; F=atof ("123.00"); LR _output_message ("%f", f); The result of the output would be 1244128.00, not what we wanted at all. Because the float,double type differs in length on different platforms, the LoadRunner
Several traps in the loadrunner function in software testing
1, Atof
In LoadRunner , if you use Direct
float F;
F=atof ("123.00");
LR_output_message ("%f", f);
The result of the output would be 1244128.00, not what we wanted at all.
Because the float,double type differs in length on different platforms, calling Atof in LoadRunner requires an explicit declaration of this function.
As follows:
Doubleatof (const char *string);
float F;
F=atof ("123.00");
Lr_output_message ("%.2f", f);
This will result in output: 123.00.
In fact, this is mentioned in LR 's Help document description for Atof, which requires that the function be used before "must be explicitly declared in Vugen scripts." ", the same requirement also appears in the description of the ATOL function.
2, Lr.save_string
In LoadRunner, when using. NET VUser, you can use lr.save_string to store a variable, but its use differs from the lr_save_string that is commonly used, and it is easy to "recruit" by careless words.
The lr_save_string of C language is defined as follows:
int lr_save_string (const char *param_value, const char *param_name);
Note: The parameter value is in front, and the parameter name is behind
Instead, the. NET vuser lr.save_string parameters are used in the opposite direction, and the parameter values should be placed behind.
However, LR's help document does not have a definition of lr.save_string, and if you select "Lr.save_string" in the script and then press F1, it jumps directly into the definition description of lr_save_string, which is very easy to mislead people!
3, Ftp_put
Ftp_put is an FTP function in LoadRunner for uploading files to an FTP server . Defined as follows:
int Ftp_put (char *transaction, last);
See the Help documentation for LR for an example:
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);
When you think it's time to take it and modify it, LR prompts the following error:
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 is called from an action.
The error is that the file is unreadable, but the file is not in the D:\LoadRunner\LRProject\lr_FTP1\test.txt indicated by the error, but in the d:/ftp.txt.
After seeing the error prompt, a warning wrote that Path=d:/ftp.txt was not ftp_put valid option, did the error arise here? View Help documentation about Item_list Description:
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 is not specified, all the files in the Msource_path is uploaded.
Target_path (optional)-the PATH and filename in which to place the file.
if (M) Source_path is specified, but target_path are not specified, the file was stored in the root directory of the FTP serv Er, 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)
The original is Source_path instead of the example of the path, OK, when you change to Source_path, as follows:
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);
Xing hurried to think on the line, a run and error:
Globals.h (101): Error-86025:put failed; 550/pub/for_jon:not a regular file
It turns out this is a target_path problem, and then look at LR's Help documentation:
Target_path (optional)-the PATH and filename in which to place the file.
if (M) Source_path is specified, but target_path are not specified, the file was stored in the root directory of the FTP serv Er, with the original file name.
The original target_path to include the file name, so change to:
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);
It's finally done this time.
Similarly, there are similar errors in the FTP_PUT_EX function:
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);
And the example code is written "FTP_PUT_EX", describing the example is said to be "FTP_GET_EX".
Several traps in the LoadRunner function in software testing