In some cases in our load test scenarios we need to get the sampler, thread group or even test plan names ans save them as varables.
For example you can send email notification with text like this:
To accomplish this we have three functions, so we may use them in BeanShell:
__samplerName()function returns the name (i.e. label) of the current sampler. The function does not work in Test elements that don’t have an associated sampler. For example the Test Plan. Configuration elements also don’t have an associated sampler. However some Configuration elements are referenced directly by samplers, such as the HTTP Header Manager and Http Cookie Manager, and in this case the functions are resolved in the context of the Http Sampler. Pre-Processors, Post-Processors and Assertions always have an associated Sampler.
__TestPlanName()function returns the name of the current test plan (can be used in Including Plans to know the name of the calling test plan). Example:
__TestPlanNamewill return the File name of Test Plan, which can be different with Test Plan Name.
__threadGroupName()function simply returns the name of the thread group being executed. Example: