一款Python生成JMeter脚本的工具。
Project description
JMeter脚本生成工具
一款Python生成JMeter脚本的工具。
使用说明
初始化JMeter脚本
from jmetertools import JMeter
jmeter_script = JMeter.get()
创建hashtree
hash_tree = ET.SubElement(jmeter_script, 'hashTree')
创建测试计划
from jmetertools.JMeter import JMeterTestPlan
test_plan = JMeterTestPlan()
test_plan = test_plan.get(hash_tree)
添加线程组
from jmetertools.JMeter import JMeterThreadGroup
thread_group_tree = ET.SubElement(hash_tree, 'hashTree')
thread_group = JMeterThreadGroup().get(thread_group_tree)
添加HTTP请求取样器
详细设置代码中有注释
from jmetertools.JMeter import JMeterHttpSampler
http_sampler = JMeterHttpSampler()
http_sampler.set_method('post')
http_sampler.set_protocol('http')
http_sampler.set_domain('127.0.0.1')
http_sampler.set_port('8080')
http_sampler.set_contentEncoding('UTF-8')
http_sampler.set_postBodyRaw({"test1": "test2"})
http_sampler.set_params({'test': 123})
http_sampler.set_files({'file': 'test.txt'})
# test_hashtree为http请求取样器的父级
http_sampler.get(test_hashtree)
其他取样器、监听器、配置元件等,可以查看core/__JMeter * .py代码中的注释。
运行测试脚本
修改config.yaml配置文件,将jmeter_home修改为本地JMeter的bin目录
from jmetertools import JMeter
# jmx_file:jmeter脚本
# result_file:结果文件
# result_dir:结果保存目录
JMeter.run_jmeter_test(jmx_file, result_file, result_dir)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file JMeterTools-1.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: JMeterTools-1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 38.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c4a9216f9660a4e3d28d0482edde876efb14cc72885e3ace511510818d01748
|
|
| MD5 |
ad36b9aa379375fe1b0efb717e567534
|
|
| BLAKE2b-256 |
e57a04b62d8f090c3703bf673d6318cf44aad040d9e64e2f665c5845f28e96cc
|