Jmeter If控制器带有http代码 [英] Jmeter If controller with http code
问题描述
我想在我的jmeter负载测试中使用if控制器.测试是:
I want to use if controller in my jmeter load testing. The test is:
- 发表评论并获取访问令牌.
- 使用该访问令牌获取下一个链接.
我的问题:
我有访问令牌,并且使用了断言后->正则表达式提取器,并从他的http响应中获取了访问令牌.但是现在我不知道如何使用if控件,并且仅在http响应代码为200时才要求它进行下一个测试.第二个问题是我是否仍可以将访问令牌的正则表达式值传递给if循环的http标头管理器?
I have the access token and have used the post-assertion->regular expression extractor and got the access token from he http response. But now I don't know how to use the if control and ask it do next test only if the http response code is 200. And second question is can i still pass my regular expression value of access token into the if loop's http header manager?
附上我的jmeter的屏幕截图.
attaching the screen shot of my jmeter.
推荐答案
尝试使用响应断言来处理Request_Access_Token请求的状态(成功/失败),具体取决于返回的响应代码,然后将IfController与预定义的
Try to use Response Assertion to handle state of Request_Access_Token request (success/failure) depending on Response Code returned and then use IfController along with pre-defined JMeterThread.last_sample_ok jmeter's variable - whether or not the last sample was OK - true/false.
架构如下所示:
ThreadGroup
Request_Access_Token
Response Assertion
Response Field to Test: Response Code
Pattern Matching Rules: Equals
Patterns to Test: 200
Regex Extractor // your Access_Token extractor
IfController
Condition: ${JMeterThread.last_sample_ok} // will be TRUE if Response Assertion above is TRUE (i.e. response code = 200)
HttpRequest
// send extracted Access_Token along with request
...
这篇关于Jmeter If控制器带有http代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!