While working on jmeter functions, tried following functions in scripting
- For logging in log file, we can use following function in <BeanShell Postprocessor> OR <BeanShell Sampler>
1. ${__log("-Thread Number---------------${__threadNum()} --------------")};
sample output :-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Thread Number---------------1 --------------"
2. ${__log("-Counter---------------${__counter(true,c)} --------------")};
sample output :-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Counter---------------38 --------------"
3. ${__log("-Request/Sampler---------------${__samplerName(s)}--------------")};
sample outout :-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Request/Sampler---------------/static/94262ec5/images/48x48/notepad.png--------------"
4. ${__log("----------------${__machineIP(ip)}--------------")};
${__log("----------------${__machineName(mname)}--------------")};
${__log("-Time---------------${__time(YMDHMS)} --------------")};
sample output in log file:-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Time---------------20150518-112329 --------------"
${__log("----------------Success--------------")};
${__log("-split---------------${__split(testamark,var,a)} --------------")};
${__log("-Var1---------------${var_1} --------------")};
${__log("-Var2---------------${var_2} --------------")};
${__log("-Var3---------------${var_3} --------------")};
sample output:-
jmeter.functions.LogFunction: Thread Group 1-1 : "-split---------------testamark --------------"
jmeter.functions.LogFunction: Thread Group 1-1 : "-Var1---------------test --------------"
jmeter.functions.LogFunction: Thread Group 1-1 : "-Var2---------------m --------------"
jmeter.functions.LogFunction: Thread Group 1-1 : "-Var3---------------rk --------------"
${__log("-Property Value---------------${__property(user.dir)} --------------")};
sample output:-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Property Value---------------D:\data_bkup\PEG\apache-jmeter-2.7\apache-jmeter-2.7\bin --------------"
- For logging in log file, we can use following function in <BeanShell Postprocessor> OR <BeanShell Sampler>
1. ${__log("-Thread Number---------------${__threadNum()} --------------")};
sample output :-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Thread Number---------------1 --------------"
2. ${__log("-Counter---------------${__counter(true,c)} --------------")};
sample output :-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Counter---------------38 --------------"
3. ${__log("-Request/Sampler---------------${__samplerName(s)}--------------")};
sample outout :-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Request/Sampler---------------/static/94262ec5/images/48x48/notepad.png--------------"
4. ${__log("----------------${__machineIP(ip)}--------------")};
${__log("----------------${__machineName(mname)}--------------")};
${__log("-Time---------------${__time(YMDHMS)} --------------")};
sample output in log file:-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Time---------------20150518-112329 --------------"
${__log("----------------Success--------------")};
${__log("-split---------------${__split(testamark,var,a)} --------------")};
${__log("-Var1---------------${var_1} --------------")};
${__log("-Var2---------------${var_2} --------------")};
${__log("-Var3---------------${var_3} --------------")};
sample output:-
jmeter.functions.LogFunction: Thread Group 1-1 : "-split---------------testamark --------------"
jmeter.functions.LogFunction: Thread Group 1-1 : "-Var1---------------test --------------"
jmeter.functions.LogFunction: Thread Group 1-1 : "-Var2---------------m --------------"
jmeter.functions.LogFunction: Thread Group 1-1 : "-Var3---------------rk --------------"
${__log("-Property Value---------------${__property(user.dir)} --------------")};
sample output:-
INFO - jmeter.functions.LogFunction: Thread Group 1-1 : "-Property Value---------------D:\data_bkup\PEG\apache-jmeter-2.7\apache-jmeter-2.7\bin --------------"
Thanks for sharing your functions usage cases, Mahesh. Just in case if you missed something check out How to use JMeter Functions post series which highlights main JMeter functions and provides missing documentation where is a gap in the official user manual.
ReplyDeleteSure Glinius, will update function usage accordingly.
Delete