jmeter可以作为API监控测试的工具,http://jmeter.apache.org/usermanual/index.html 中有非常详细使用介绍
可以分为三个部分:
1. API的http请求
2.生成测试报告,可以通过修改jmeter-results-detail-report_21.xsl微调格式
3. 出错发送告警邮件或短信
这些是周期性运行的,所以可以使用jenkins进行管理。
使用如果需要验证返回内容的正确性,可以同时保存每次请求的结果(需要在每个http请求下添加simple data writer),结果的格式可以在bin/jmeter.properties下设置:
jmeter.save.saveservice.output_format=xml
# true when field should be saved; false otherwise
# assertion_results_failure_message only affects CSV output
#jmeter.save.saveservice.assertion_results_failure_message=false
#
# legitimate values: none, first, all
jmeter.save.saveservice.assertion_results=all
#
#jmeter.save.saveservice.data_type=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
# response_data is not currently supported for CSV output
#jmeter.save.saveservice.response_data=true
# Save ResponseData for failed samples
#jmeter.save.saveservice.response_data.on_error=false
#jmeter.save.saveservice.response_message=true
jmeter.save.saveservice.successful=true
#jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.subresults=true
#jmeter.save.saveservice.assertions=true
jmeter.save.saveservice.latency=true
#jmeter.save.saveservice.samplerData=false
#jmeter.save.saveservice.responseHeaders=false
#jmeter.save.saveservice.requestHeaders=false
#jmeter.save.saveservice.encoding=false
jmeter.save.saveservice.bytes=true
jmeter.save.saveservice.url=true
#jmeter.save.saveservice.filename=false
#jmeter.save.saveservice.hostname=false
#jmeter.save.saveservice.thread_counts=false
#jmeter.save.saveservice.sample_count=false
#jmeter.save.saveservice.idle_time=false