You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Tong Sun <su...@gmail.com> on 2022/07/24 15:54:23 UTC
how to change the user defined variable?
Hi,
How do you change the user defined variable?
The same question has been asked before, like under
https://guide.blazemeter.com/hc/en-us/articles/207421395-Using-User-Defined-Variables,
but I found no good answers.
Unlike placing them under Thread Group or Sampler, I need to
- define UDV under the Test Plan, and use those UDVs to
parameterize/control my Thread Group.
- and change them after UDV definition but before applying to the Thread
Groups
For e.g., pseudo code:
if isSpecifyingThreadLifetime then LoopCount = 1000000
How can I do that? Thx!
Re: how to change the user defined variable?
Posted by Dmitri T <gl...@live.com>.
Not sure whether this answer is "good" enough for you, however you can
do something like:
1. Add setUp Thread Group
<https://www.blazemeter.com/blog/thread-group-jmeter> to your Test plan
2. Add JSR223 Sampler
<https://jmeter.apache.org/usermanual/component_reference.html#JSR223_Sampler>
to the setUp Thread Group and use the following code there:
defengine=engine=ctx.getEngine()
deftest=engine.getClass().getDeclaredField('test')
test.setAccessible(true)
deftestPlanTree=test.get(engine)
defthreadGroupSearch=neworg.apache.jorphan.collections.SearchByClass<>(org.apache.jmeter.threads.ThreadGroup.class)
testPlanTree.traverse(threadGroupSearch)
defthreadGroup=threadGroupSearch.getSearchResults().find{threadGroup->threadGroup.getName()=='name
of your thread group here'}
if(threadGroup.getPropertyAsBoolean('ThreadGroup.scheduler')){
threadGroup.getSamplerController().setLoops(1000000)
}
On 7/24/2022 5:54 PM, Tong Sun wrote:
> Hi,
>
> How do you change the user defined variable?
>
> The same question has been asked before, like under
> https://guide.blazemeter.com/hc/en-us/articles/207421395-Using-User-Defined-Variables,
> but I found no good answers.
>
> Unlike placing them under Thread Group or Sampler, I need to
>
> - define UDV under the Test Plan, and use those UDVs to
> parameterize/control my Thread Group.
> - and change them after UDV definition but before applying to the Thread
> Groups
>
> For e.g., pseudo code:
>
> if isSpecifyingThreadLifetime then LoopCount = 1000000
>
> How can I do that? Thx!
>