Expected behavior
The __RandomDate function should treat the provided end date as inclusive. When the start and end dates are the same, the function should simply return that single date (and store it in the target variable) instead of failing.
Actual behavior
-
When startDate < endDate, the function never returns the configured end date. It behaves as if the interval were [start, end) (exclusive upper bound).
-
When startDate == endDate, the call to ThreadLocalRandom.nextLong(start, end) raises IllegalArgumentException: bound must be greater than origin, so the function errors out instead of returning the only valid date.
Steps to reproduce the problem
- Create a test plan with a Debug Sampler and a Simple Data Writer (or just watch the Debug Sampler output).
- Add a User Parameters or a JSR223 Sampler to evaluate
${__RandomDate(yyyy-MM-dd,2111-03-29,2111-03-30,,MY_VAR)}.
- Run the plan multiple times. Observe that the logged value is always
2111-03-29 and MY_VAR never contains 2111-03-30.
- Change the call to
${__RandomDate(yyyy-MM-dd,2111-03-29,2111-03-29,,MY_VAR)} and run again. The sampler now fails with the IllegalArgumentException mentioned above.
JMeter Version
6.0.0-SNAPSHOT
Java Version
OpenJDK Runtime Environment 21.0.8 (2025-07-16)
OS Version
Linux 6.6.87.2-microsoft-standard-WSL2 (running under Windows 11 / WSL2)
Expected behavior
The
__RandomDatefunction should treat the provided end date as inclusive. When the start and end dates are the same, the function should simply return that single date (and store it in the target variable) instead of failing.Actual behavior
When
startDate < endDate, the function never returns the configured end date. It behaves as if the interval were [start, end) (exclusive upper bound).When
startDate == endDate, the call toThreadLocalRandom.nextLong(start, end)raisesIllegalArgumentException: bound must be greater than origin, so the function errors out instead of returning the only valid date.Steps to reproduce the problem
${__RandomDate(yyyy-MM-dd,2111-03-29,2111-03-30,,MY_VAR)}.2111-03-29andMY_VARnever contains2111-03-30.${__RandomDate(yyyy-MM-dd,2111-03-29,2111-03-29,,MY_VAR)}and run again. The sampler now fails with theIllegalArgumentExceptionmentioned above.JMeter Version
6.0.0-SNAPSHOT
Java Version
OpenJDK Runtime Environment 21.0.8 (2025-07-16)
OS Version
Linux 6.6.87.2-microsoft-standard-WSL2 (running under Windows 11 / WSL2)