Jmeter关联实例
流程:
步骤:
1.新建线程组、HTTP默认值、HTTP请求
2.使用正则表达式提取器,提取typeId和newsId
获取所有新闻类型列表>>add>>Post Processors>>Regular Expression Extractor(提取typeId)
调用typeId获取新闻列表>>add>>Post Processors>>Regular Expression Extractor(提取newsId)
添加调试工具Debug Sampler:线程组>>add>>sampler>>Debug Sampler
添加view result tree,运行查看结果
脚本内容:
HTTP Resquest Defaults : https www.mxnzp.com
获取所有新闻类型列表: /news/types?app_id={你的app_id}&app_secret={你的app_secret}
调用typeId获取新闻列表: /news/list?app_id={你的app_id}&app_secret={你的app_secret}
调用newsId获取新闻详情: /news/details?app_id={你的app_id}&app_secret={你的app_secret}
提取typeId正则表达式
提取newsId正则表达式
3.使用JSON提取器,提取typeId和newsId
提取typeId
提取newsId正则表达式
注:1.感谢作者提供免费接口让我测试,接口链接:https://github.com/MZCretin/RollToolsApi 脚本中app_id&app_secret的值根据此接口文章步骤获得
2.正则表达式要书写规范,不能有多余的空格、必须要加圆括号、提取带有双引号的参数时,正则表达式也必须加上双引号。