apache / apache/jmeter

ForEach Controller Start index for loop not using variable

Open
#6,108 1 comment 0 reactions 0 assignees View on GitHub
defect enhancement help-wanted
Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Description

### Expected behavior

I want to control the Start and End index of the ForEach controller using a variable.
At the start of the test I don't know what the value of the Start and End index will be.
Sometimes I want to start at index 5, sometimes at 0, sometimes at 3.

### Actual behavior

When the Start index of the ForEach controller is set using a variable, it is not used. The start index is still 0.
In my test plan I want to set the variable at some point in time during the test (based upon changing factors).

In the attached (simplyfied) testplan, I am using some dummy/demo values to demonstrate the issue.

When I add a User Defined Variables config element to the plan, the ForEach controller is using the Start index set specified in that variable, but that does not help me as I want it to be more dynamic.

### Steps to reproduce the problem

The test plan starts by creating JSON content and I use a JSON Extractor to create a number of variables which then can be used by the ForEach Controller.

[ForeachTest.jmx.txt](https://github.com/apache/jmeter/files/13419020/ForeachTest.jmx.txt)

After extracting the variables, there is a JSR223 PostProcessor which sets the variables used for the Start and End Index.
The Start index is set to 2, the End index is set to 5. So I am expecting the ForEach controller to use variable 3, 4, and 5.
The End Index is working fine but the Start Index is ignored.

![image](https://github.com/apache/jmeter/assets/13550012/5e4d88d8-0d46-4e16-9b73-3b87115320db)

### JMeter Version

5.6.2

### Java Version

java version 1.8.0_391

### OS Version

Windows 11 22H2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.