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
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
3. Add a thread group, add a sampler to the thread group, and select JSR223 as the sampler
4. Select python for scripting language
5. Pass in python code and execute
5.1) First add a listener [view result count]
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)
5.3) View the execution results as follows: