jmeter的新增函數說明


本文算是對《零成本實現Web性能測試:基於Apache JMeter》中的《詳解JMeter函數和變量》進行狗尾續貂哈,因為最近版本的jmeter增加了幾個新函數,在原書中沒有說明,我在這里翻譯一下英文原文。我更推薦大家去jmeter的官網查找函數定義。http://jmeter.apache.org/usermanual/functions.html

Type of function

Name

Comment

Since

Information

__threadNum

get thread number

1.X

Information

__samplerName

get the sampler name (label)

2.5

Information

__machineIP

get the local machine IP address

2.6

Information

__machineName

get the local machine name

1.X

Information

__time

return current time in various formats

2.2

Information

__log

log (or display) a message (and return the value)

2.2

Information

__logn

log (or display) a message (empty return value)

2.2

Input

__StringFromFile

read a line from a file

1.9

Input

__FileToString

read an entire file

2.4

Input

__CSVRead

read from CSV delimited file

1.9

Input

__XPath

Use an XPath expression to read from a file

2.0.3

Calculation

__counter

generate an incrementing number

1.X

Calculation

__intSum

add int numbers

1.8.1

Calculation

__longSum

add long numbers

2.3.2

Calculation

__Random

generate a random number

1.9

Calculation

__RandomString

generate a random string

2.6

Calculation

__UUID

generate a random type 4 UUID

2.9

Scripting

__BeanShell

run a BeanShell script

1.X

Scripting

__javaScript

process JavaScript (Mozilla Rhino)

1.9

Scripting

__jexl, __jexl2

evaluate a Commons Jexl expression

jexl(2.2), jexl2(2.6)

Properties

__property

read a property

2

Properties

__P

read a property (shorthand method)

2

Properties

__setProperty

set a JMeter property

2.1

Variables

__split

Split a string into variables

2.0.2

Variables

__V

evaluate a variable name

2.3RC3

Variables

__eval

evaluate a variable expression

2.3.1

Variables

__evalVar

evaluate an expression stored in a variable

2.3.1

String

__regexFunction

parse previous response using a regular expression

1.X

String

__escapeOroRegexpChars

quote meta chars used by ORO regular expression

2.9

String

__char

generate Unicode char values from a list of numbers

2.3.3

String

__unescape

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

2.3.3

String

__unescapeHtml

Decode HTML-encoded strings

2.3.3

String

__escapeHtml

Encode strings using HTML encoding

2.3.3

String

__urldecode

Decode a application/x-www-form-urlencoded string

2.1

String

__urlencode

Encode a string to a application/x-www-form-urlencoded string

2.1

String

__TestPlanName

Return name of current test plan

2.6


__samplerName

函數samplerName用來返回當前采樣器的名稱

函數參數

描述

是否必需

變量名

一個引用名(refName),目的是復用這一函數創建的值。可以使用語法${refName}來引用函數創建的值。

 


__machineIP

函數machineIP用來返回當前機器的ip地址。它使用Java方法InetAddress.getLocalHost()並將其傳遞到getHostAddress()

函數參數

描述

是否必需

變量名

一個引用名(refName),目的是復用這一函數創建的值。


__RandomString

函數RandomString用來返回指定長度的隨機字符串。

函數參數

描述

是否必需

長度

創建的字符串的長度

指定字符

用於創建字符串的字符

變量名

一個引用名(refName),目的是復用這一函數創建的值。可以使用語法${refName}來引用函數創建的值。


__UUID

函數UUID用來返回偽造的隨機的標准唯一識別碼


__escapeOroRegexpChars

函數escapeOroRegexpChars用於轉義正則表達式中的字符,相當於Java的正則表達式引擎中的\Q、\E。

例如[^"].+? 會被轉換為\[\^\"\]\.\+\?

函數參數

描述

是否必需

待轉義字符串

待轉義字符串

變量名

一個引用名(refName),目的是復用這一函數創建的值。可以使用語法${refName}來引用函數創建的值。

 


__urldecode

函數urldecode用於解密application/x-www-form-urlencoded這種類型的字符串,注意:使用UTF8編碼方案

例如,字符串Word+%22school%22+is+%22%C3%A9cole%22+in+french  會被轉換為  Word "school" is "école" in french

使用了java的URLDecoder

函數參數

描述

是否必需

待解密的字符串

待解密的字符串


__urlencode

函數urlencode用於加密一個字符串成為application/x-www-form-urlencoded類型的字符串

例如,字符串Word "school" is "école" in french 會被轉換為 Word+%22school%22+is+%22%C3%A9cole%22+in+french

使用了java的 URLEncoder.類

函數參數

描述

是否必需

待加密的字符串

待加密的字符串


__TestPlanName

函數TestPlanName用於返回當前測試計划的名字


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM