Unable to set incremental variable in Jmeter

后端 未结 1 1956
闹比i
闹比i 2021-01-27 07:48

Here is my simple Jmeter test plan.

User Parameters look like this:

I\'m simply calling one endpoint, reading the response body and according t

1条回答
  •  鱼传尺愫
    2021-01-27 08:16

    1. Be aware that starting from JMeter version 3.1 it is recommended to use Groovy for any form of scripting to consider migrating to JSR223 PostProcessor

    2. Looking into repeating 'DayOfWeek':'xxx' pattern it seems you don't need to create 7 branches for each weekday, you can extract the current value using Regular Expressions and set or get and increment the relevant JMeter Variable

    Example code would be something like:

    def day = (prev.getResponseDataAsString() =~ "'DayOfWeek':'(\\w+)'")[0].get(1)
    def value = (vars.get(day) ?: '0') as int
    value++
    vars.put(day, value as String)
    

    See Apache Groovy - Why and How You Should Use It article for more information on using Groovy scripting in JMeter tests

    0 讨论(0)
提交回复
热议问题