apache / apache/jmeter

Harmonize keys for bindings (i. e. JSR223-Elements)

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

Description

### Expected behavior

When shifting my test setup from `JSR223Asstions` to `JSR223Listener` (with the same groovy code) I can execute the same code without errors.

Code:
```
...
if (!vars.get("login_session")?.trim() && ctx.getCurrentSampler().getName().contains("0030_Do Authenticate")) {
SampleResult.setResponseMessage("login_session not returned by step 0030")
SampleResult.setSuccessful(false)
}
...
```

### Actual behavior

When "blindly" shifting and executing the code I get the error:

```
ERROR o.a.j.v.JSR223Listener: Problem in JSR223 script, Handle Results
javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: SampleResult for class: Script28
```

When diving into the code, I noticed that `sampleResult` and `SampleResult` are used:
`sampleResult` in `JSR223Listener` and `JavaScript`
`SampleResult` in `JSR223Sampler` and `JSR223Assertion`

It would be nice to have the same bindings within all languages and elements (Groovy, Jexl, JavaScript, Assertions, Listeners, ...)

### Steps to reproduce the problem

Run this code in JSR223 Assertion and in JSR223 Listener
```
if (!vars.get("login_session")?.trim() ) {
SampleResult.setResponseMessage("login_session not returned by step 0030")
SampleResult.setSuccessful(false)
}
```

### JMeter Version

5.6.3

### Java Version

openjdk version "21.0.2" 2024-01-16 LTS

### OS Version

Microsoft Windows [Version 10.0.19045.5011]

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.