---
swagger: '2.0'
info:
version: 1.0.0
title: Echo
description: |
#### Echos back every URL, method, parameter and header
Feel free to make a path or an operation and use **Try Operation** to test it. The echo server will
render back everything.
schemes:
- http
host: mazimi-prod.apigee.net
basePath: /echo
paths:
/{id}:
get:
parameters:
- name: id
in: path
description: ID
type: string
required: true
- name: user
in: query
description: name
type: string
required: true
- name: location
in: query
description: location
type: string
required: true
responses:
200:
description: Echo GET
1 回答
我为不同的API生成了JMeter(JMX)并且我让它工作,虽然有一些问题和警告 .
First it generates
用户定义的变量,可在Host,Port,testCases,csvFileName中替换
每个API的JMX
每个方法一个线程组(POST,GET,..)
每个线程组的HTTP标头管理器,空白但有用 .
每个请求的HTTP采样器
加载CSV数据以填充参数值
HTTP状态断言,在CSV文件中定义的错误代码上验证
Caveats and Issues
它不会使主机远离配置,它将替换为本地主机 . 您必须更改它或通过命令行传递它
它使用默认端口8080,这也让我感到悲伤 .
循环计数由变量testCases控制 . 但是,如果您想通过命令行传递此信息,则JMeter的swagger-code-gen模板中存在一个错误
testCases变量在模板中有一个错误,它将testCases定义为$ {__ P(host,10)}但它应该是$ {__ P(testCases,10)}
GET参数填充0而不是$ ,这是来自swagger codegen中的template . 我已经测试了我的叉子中的修复程序 . 另一种选择就是将其修复为JMX文件原始
并在编辑参数后
Example Swagger that works
以下是我使用的Swagger file(从echo修改)和生成的(修改了参数)JMX . 我使用RedLine13 Example Test测试了这个JMX并根据需要传递参数 . 传递参数
这是Yaml的例子
Updated JMEter template in Swagger CodeGen
由于在SwaggerCode Gen中使这项工作无缝存在一些问题,我创建了一个issue and pull request . 如果您需要尽快使用叉子这里https://github.com/richardfriedman/swagger-codegen/commit/5aff601eaccf67ec44bb681816d40a25e5aa20a3