You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Thiago Berne <th...@gmail.com> on 2019/09/10 22:23:20 UTC

Enable listener based on a condition

Hey guys,
I'm trying to add a debug feature in a Jmeter script. This script is ran in
non-gui mode, receiving a lot of parameters. I'm receiving one more
parameter named 'debug'.
I would like to enable a 'View Results Tree' listener if this variable
equals to 'true'.
I tried to add the listener inside an if controller but it didn't work.
I tried to change  *enabled="true"* to  *enabled="${debug}"* in view tree
controller XML node but it didn't work either.
Is there a way of doing that?
PS: running the script in GUI mode is not an option for me.

Thanks!

Thiago Gagliano Berne

Re: Enable listener based on a condition

Posted by Scott Dean <ps...@ncsu.edu>.
Greetings!

I am not sure this will do what you want in the way you want but here is an
idea:


   1. add a "View Results Tree" listener and define a output file and set
   it only to record errors
   2. In the place you want to capture the debug information, insert an
   "IF" controller that tests for the value of ${debug}.
   3. Inside the "If" controller, put a Dummy Sampler and mark it an
   unsuccessful sample.  This will cause the sample to be written to the
   output file for the "View Results Tree"; you can use the Request Data
   and/or Response Data fields to capture the values of variables and
   properties  that you want to surface.
      1. You could also use something like a JSR223 Sampler and
      programmatically mark the sample as a failed, and it would potential give
      you the ability to output whatever other data you might want and
do things
      like write to info to the jmeter.log file.
      2. I guess you could also just have an response assertion that test
      the value of debug and fails;

Of course, any other samples that come back as failed will also end up in
the View Results Tree file.

Note: I have not actually implemented and tested any of this so YMMV.

HTH!

-- Scott Dean
    OIT/Shared Services/AIS]
   North Carolina State Universty.
   Raleigh, NC



On Tue, Sep 10, 2019 at 6:23 PM Thiago Berne <th...@gmail.com> wrote:

> Hey guys,
> I'm trying to add a debug feature in a Jmeter script. This script is ran in
> non-gui mode, receiving a lot of parameters. I'm receiving one more
> parameter named 'debug'.
> I would like to enable a 'View Results Tree' listener if this variable
> equals to 'true'.
> I tried to add the listener inside an if controller but it didn't work.
> I tried to change  *enabled="true"* to  *enabled="${debug}"* in view tree
> controller XML node but it didn't work either.
> Is there a way of doing that?
> PS: running the script in GUI mode is not an option for me.
>
> Thanks!
>
> Thiago Gagliano Berne
>