Skip to content

feat: allow expressions for TestElement.enabled property #6478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vlsi
Copy link
Collaborator

@vlsi vlsi commented Jul 22, 2025

Description

This is a proof-of-concept implementation for conditional TestElement.enabled.
The downside is that isEnabled() call would be added for every sampler, listener, pre-processor, pos-processor, and so on which might slow down the execution.

Motivation and Context

See #6006

How Has This Been Tested?

See EnabledWithVariablesTest

Screenshots (if appropriate):

WIP:
debug sampler with expression in enable property

<hashTree>
  <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
    <boolProp name="displayJMeterProperties">false</boolProp>
    <boolProp name="displayJMeterVariables">true</boolProp>
    <boolProp name="displaySystemProperties">false</boolProp>
  </DebugSampler>
  <hashTree/>
  <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="false">
    <boolProp name="displayJMeterProperties">false</boolProp>
    <boolProp name="displayJMeterVariables">true</boolProp>
    <boolProp name="displaySystemProperties">false</boolProp>
  </DebugSampler>
  <hashTree/>
  <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="${__javaScript(false)}">
    <boolProp name="displayJMeterProperties">false</boolProp>
    <boolProp name="displayJMeterVariables">true</boolProp>
    <boolProp name="displaySystemProperties">false</boolProp>
  </DebugSampler>
  <hashTree/>
</hashTree>

Checklist:

  • UI: select the location and the control style
  • UI: implement saving the plan to jmx
  • UI: implement loading the plan from jmx
  • Verify if TestBean-based components work as well
  • Support ..RequestDefaults. The logic of merge...Element probably needs ignoring disabled elements
  • Decide if interface JMeterGUIComponent needs to support expressions. Currently there's boolean getEnabled() and setEnabled(boolean)
  • Add documentation
  • Analyze if the following is still needed:
    // This check the state of the TestElement and if returns false it
    // disable the loaded node
    try {
    newNode.setEnabled(component.isEnabled());
    } catch (Exception e) { // TODO - can this ever happen?
    newNode.setEnabled(true);
    }

@vlsi vlsi force-pushed the conditional_enable branch from bca6bb1 to 1e4051e Compare July 23, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant