Getting started with Jmeter (3) calling python script (with case)

Preface

This chapter mainly describes the method of using Jmeter to call python scripts


1. Tutorial steps

1. Download the jython package

1. Official website download URL: https://www.jython.org/downloads.html
Insert picture description here

2. Resource download
link: http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar


2. Put the downloaded jar package in the lib directory of Jmeter, and restart Jmeter

Insert picture description here

3. Add a thread group, add a sampler to the thread group, and select JSR223 as the sampler

Insert picture description here
Insert picture description here

4. Select python for scripting language

Insert picture description here

5. Pass in python code and execute

5.1) First add a listener [view result count]
Insert picture description here

5.2) Input python script and click to execute

#获取jmeter 参数
param =vars.get("param")
print "hello"
#设置响应信息
SampleResult.setResponseData("message");
SampleResult.setResponseCode("502")
SampleResult.setSuccessful(False)

Insert picture description here

5.3) View the execution results as follows:
Insert picture description here

Guess you like

Origin blog.csdn.net/Makasa/article/details/107558789