Jmeter - 使用单次调用的GETPOST - While循环

问题描述 投票:0回答:1

基于 Jmeter - 使用单次调用的GETPOST。 我试着用单次调用来执行GETPOST调用,如果我不使用数据源,解决方案就能正常工作。

但是,在我的测试中,我已经使用csv文件作为数据源。我目前的设置是这样的。

TC_name, login_id, excpecedCode
test_with_valid_login_id,2132537288,200
test_with_unknown_login_id,11111,200
test_with_known_login_id,1,200
test_with_invalide_login_id,dsddfd,400
test_with_negative_login_id,-100,400

enter image description here

enter image description here

在csv文件中,我有5个测试用例,这5个测试用例驱动我的测试。如果我尝试添加第二个csv文件,我无法对每个测试用例进行GETPOST操作。

我尝试添加

enter image description here

但是,我仍然无法根据csv数据配置中的5个测试用例获得10次执行。

什么是最简单的设置,让我可以在csv驱动的While循环上面同时运行GETPOST的测试?

jmeter
1个回答
1
投票

你为什么不直接改变你的CSV文件,以包括以下内容 HTTP请求方式 以及所有其他参数,如。

TC_name, login_id, excpecedCode, method
test_with_valid_login_id,2132537288,200,GET
test_with_valid_login_id,2132537288,200,POST
test_with_unknown_login_id,11111,200,GET
test_with_unknown_login_id,11111,200,POST
test_with_known_login_id,1,200,GET
test_with_known_login_id,1,200,POST
test_with_invalide_login_id,dsddfd,400,GET
test_with_invalide_login_id,dsddfd,400,POST
test_with_negative_login_id,-100,400,GET
test_with_negative_login_id,-100,400,POST

如果CSV文件不是你能控制的,那么你可以...

  1. 创建一个简单的文本文件,名为 methods.txt 在JMeter安装的 "bin "文件夹中,看起来像。

    GET
    POST
    
  2. 将您要重复的请求放在 环路控制器 带2个环路
  3. 使用以下内容 __groovy()函数 而不是 ${method} 在HTTP请求采样器中。

    ${__groovy(new File('methods.txt').readLines().get(vars.get('__jm__Loop Controller__idx') as int),)}
    
© www.soinside.com 2019 - 2024. All rights reserved.