jMeter Functions - JMeter

What is jMeter Functions?
JMeter functions and user Variables

  • JMeter functions are unique values that can populate fields of any Sampler or different detail in a test tree.

A function name looks like this −

  • _functionName matches the name of a function. for instance ${__threadNum}.
  • If a function parameter includes a comma, then make sure you escape this with "" as proven below –

Variables are referenced as –

List of Functions

Following table lists a group of functions loosely grouped into types –

Function Type

Name

Comment

Information

threadNum

Get thread number.

Information

samplerName

Get the sampler name (label).

Information

machineIP

Get the local machine IP address.

Information

machineName

Get the local machine name.

Information

time

Return current time in various formats.

Information

log

Log (or display) a message (and return the value).

Information

logn

Log (or display) a message (empty return value).

Input

StringFromFile

Read a line from a file.

Input

FileToString

Read an entire file.

Input

CSVRead

Read from CSV delimited file.

Input

XPath

Use an XPath expression to read from a file.

Calculation

counter

Generate an incrementing number.

Calculation

intSum

Add int numbers.

Calculation

longSum

Add long numbers.

Calculation

Random

Generate a random number.

Calculation

RandomString

Generate a random string.

Calculation

UUID

Generate a random type 4 UUID.

Scripting

BeanShell

Run a BeanShell script.

Scripting

javaScript

Process JavaScript (Mozilla Rhino).

Scripting

jexl, jexl2

Evaluate a Commons Jexl expression.

Properties

property

Read a property.

Properties

P

Read a property (shorthand method).

Properties

setProperty

Set a JMeter property.

Variables

split

Split a string into variables.

Variables

V

Evaluate a variable name.

Variables

eval

Evaluate a variable expression.

Variables

evalVar

Evaluate an expression stored in a variable.

String

regexFunction

Parse previous response using a regular expression.

String

escapeOroRegexpChars

Quote meta chars used by ORO regular expression.

String

char

Generate Unicode char values from a list of numbers.

String

unescape

Process strings containing Java escapes (e.g. \n & \t).

String

unescapeHtml

Decode HTML-encoded strings.

String

escapeHtml

Encode strings using HTML encoding.

String

TestPlanName

Return name of current test plan.

  • There are two Kinds functions −
    • user-Defined static values (or variables)
    • Built-In functions
  • User-Defined static values permit the user to built-ine variables to be replaced with their static value while a test tree is compiled and submitted to be run.
  • The variables can't be nested; i.e ${Var${N}} does not work.
  • The __V (variable) feature (versions after 2.2) may be used to do that − ${__V(Var${N})}.
  • This sort of replacement is feasible with out functions, but it is less handy and less builttuitive.

Where to use functions And Variables

Functions and variables can be written built any area of any test aspect.

The following functions have to work well built a test plan –

  • IntSum
  • long Sum
  • Machine Name
  • BeanShell
  • JavaScript
  • Jexl
  • Random
  • Time
  • Property functions
  • Log functions

Functions which can be used at the test Plan have some regulations. JMeter thread variables will have not been fully set up when the features are processed, so variable names passed as parameters will now not be installation and variable references will not work. therefore, split() and regex() and the variable assessment functions will not work. The threadNum() function will not work and it does not make experience at test plan level.

Referencing Variables and Functions

  • Referencing a variable in a test detail is done by means of bracketing the variable call with '${' and '}'.
  • Functions are referenced inside the same way, however through convention, the names of functions start with "__" to avoid conflict with user value names.
  • Some features take arguments to configure them, and those cross in parentheses, comma-delimited. If the feature takes no arguments, the parentheses may be omitted. for example –

  • Alternatively, you may outline your script as a variable, e.g. on the test Plan –

  • The script can then be referenced as follows –

The Function Helper Dialog

The function Helper conversation is available from JMeter's options tab.

  • Using the feature Helper, you may choose a feature from the pull down, and assign values for its arguments. The left column table presents a quick description of the argument, and the right column is you write the Value for that argument. functions take arguments.
  • Once you have done this, click the “Generate" button, and the right is generated, which you may copy-paste the check plan anywhere you need to.

Pre-Integrated Variables

Some variables are built-in built-internally by means of JMeter. they are −

  • COOKIE_cookiename − consists of the cookie value.
  • JMeterThread.last_sample_ok − whether or now not the built-inbuiltintegrated pattern became ok − real/false. note − this is updated after PostProcessors and Assertions had been run.
  • Start variables.

Pre- Defined Properties

Some Built in properties are built-in through JMeter. those are built-in under. For comfort, the start properties also are copied to variables with the same names.

  • Start.MS − JMeter start time built milliseconds.
  • Start.YMD − JMeter start time as yyyyMMdd.
  • Start.HMS − JMeter start time as HHmmss.
  • TESTSTART.MS − test start time built-in milliseconds.

Note that the start variables / properties represent JMeter startup time, now not the test start time. they may be for use built record names etc.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JMeter Topics