情形一
脚本如下:
Action()
{
lr_start_transaction("Test");
lr_think_time(2);
lr_save_string("hello world","{ParamTest1}");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of {ParamTest1} is: %s ! ",lr_eval_string("{ParamTest1}"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
lr_end_transaction("Test",LR_AUTO);
return 0;
}
日志如下:
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(12): Notify: Transaction "Test" started. [MsgId: MMSG-16999]
Action.c(13): lr_think_time: 2.00 seconds. [MsgId: MMSG-15948]
Action.c(14): Notify: Saving Parameter "{ParamTest1} = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of {ParamTest1} is: {ParamTest1} ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Action.c(20): Notify: Transaction "Test" ended with "Pass" status (Duration: 2.0008 Think Time: 2.0002). [MsgId: MMSG-16872]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
情形二
脚本如下:
Action()
{
lr_start_transaction("Test");
lr_think_time(2);
lr_save_string("hello world","{ParamTest1}");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of \"ParamTest1\" is: %s ! ",lr_eval_string("ParamTest1"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
lr_end_transaction("Test",LR_AUTO);
return 0;
}
日志如下:
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(12): Notify: Transaction "Test" started. [MsgId: MMSG-16999]
Action.c(13): lr_think_time: 2.00 seconds. [MsgId: MMSG-15948]
Action.c(14): Notify: Saving Parameter "{ParamTest1} = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of "ParamTest1" is: ParamTest1 ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Action.c(20): Notify: Transaction "Test" ended with "Pass" status (Duration: 2.0070 Think Time: 2.0063). [MsgId: MMSG-16872]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
情形三
脚本如下:
Action()
{
lr_start_transaction("Test");
lr_think_time(2);
lr_save_string("hello world","ParamTest1");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of {ParamTest1} is: %s ! ",lr_eval_string("{ParamTest1}"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
lr_end_transaction("Test",LR_AUTO);
return 0;
}
日志如下:
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(12): Notify: Transaction "Test" started. [MsgId: MMSG-16999]
Action.c(13): lr_think_time: 2.00 seconds. [MsgId: MMSG-15948]
Action.c(15): Notify: Saving Parameter "ParamTest1 = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of {ParamTest1} is: {ParamTest1} ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Action.c(20): Notify: Transaction "Test" ended with "Pass" status (Duration: 2.0036 Think Time: 2.0029). [MsgId: MMSG-16872]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
情形四
脚本如下:
Action()
{
lr_start_transaction("Test");
lr_think_time(2); //lr_save_string("hello world","{ParamTest1}");
lr_save_string("hello world","ParamTest1");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of \"ParamTest1\" is: %s ! ",lr_eval_string("ParamTest1"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
lr_end_transaction("Test",LR_AUTO);
return 0;
}
日志如下:
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(12): Notify: Transaction "Test" started. [MsgId: MMSG-16999]
Action.c(13): lr_think_time: 2.00 seconds. [MsgId: MMSG-15948]
Action.c(15): Notify: Saving Parameter "ParamTest1 = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of "ParamTest1" is: ParamTest1 ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Action.c(20): Notify: Transaction "Test" ended with "Pass" status (Duration: 2.0142 Think Time: 2.0133). [MsgId: MMSG-16872]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
作者: 天之秦 时间: 2017-7-10 14:51
这样就可以,另外,不需要新建参数paramtest1.
Action()
{
lr_save_string("hello world","ParamTest1");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of {ParamTest1} is: %s ! ",lr_eval_string("{ParamTest1}"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
return 0;
}
输出结果:
Virtual User Script started
Starting action vuser_init.
Web Turbo Replay of LoadRunner 9.50 for WINXP; WebReplay9a build 6220 (Dec 28 2008 17:01:56) [MsgId: MMSG-27143]
Run Mode: HTML [MsgId: MMSG-26000]
Run-Time Settings file: "C:\Documents and Settings\Administrator\Local Settings\Temp\noname2\\default.cfg" [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~
The value of {ParamTest1} is: hello world !
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~
Ending action Action作者: jylizhihui 时间: 2017-7-10 15:22
Action()
{
lr_save_string("hello world","ParamTest1");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of {ParamTest1} is: %s ! ",lr_eval_string("{ParamTest1}"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
return 0;
}
日志如下
Virtual User Script started at : 2017-07-10 15:08:35 [MsgId: MMSG-15967]
Starting action vuser_init. [MsgId: MMSG-15919]
vuser_init.c(12): lrs_startup(257) [MsgId: MMSG0]
Ending action vuser_init. [MsgId: MMSG-15918]
Running Vuser... [MsgId: MMSG-15964]
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(11): Notify: Saving Parameter "ParamTest1 = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of {ParamTest1} is: {ParamTest1} ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
Starting iteration 2. [MsgId: MMSG-15968]
Notify: Next row for parameter ParamTest = 2 [table = ParamTest]. [MsgId: MMSG-13876]
Notify: Getting new value for parameter 'ParamTest': table = 'ParamTest.dat' column = '0' row = '2'. [MsgId: MMSG-13877]
Starting action Action. [MsgId: MMSG-15919]
Action.c(11): Notify: Saving Parameter "ParamTest1 = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of {ParamTest1} is: {ParamTest1} ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 2. [MsgId: MMSG-15965]