Exiting the jsr223 sampler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Exiting the jsr223 sampler

Tong Sun
Hi,

Quick & simple question, how to stop the jsr223 script from reaching
the following processing code (B), return, exit, or ...?

if (A) exit
B

I just  want the jsr223 script not to process the following code, B,
not to stop the whole thread execution, of which it's the only hits
I've found from the internet so far.

thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Exiting the jsr223 sampler

jmeter tea
Hello,

You can throw Exception, as:
if(A) {
    throw new Exception("a");
}
But usually you just put B in else,as:
 if (A) {

} else {
    B
}
or one if nothing to do when A == true:
if (!A) {
   B
}


On Thu, Feb 25, 2021 at 4:21 PM Tong Sun <[hidden email]> wrote:

> Hi,
>
> Quick & simple question, how to stop the jsr223 script from reaching
> the following processing code (B), return, exit, or ...?
>
> if (A) exit
> B
>
> I just  want the jsr223 script not to process the following code, B,
> not to stop the whole thread execution, of which it's the only hits
> I've found from the internet so far.
>
> thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Exiting the jsr223 sampler

glinius@live.com
In reply to this post by Tong Sun
return <https://www.w3schools.com/java/ref_keyword_return.asp>   keyword will
stop the sampler execution once it's reached.

If you add a string like:


> return 'A'

the JSR223 Sampler result will be *A*

no lines after the *return* keyword will be executed.

More information on Groovy scripting in JMeter:  Apache Groovy - Why and How
You Should Use It <https://www.blazemeter.com/blog/groovy-new-black>  




--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Exiting the jsr223 sampler

Mariusz W
In reply to this post by Tong Sun
Hi,
If tere is such possibility You can also use "If Controller" to check some conditions. In this controller you can use groovy code as well to check some conditions (e.g. ${__groovy(vars.get('foo') != 'boo')} - it may easier to analyzing in future when you back to script.

Mariusz
On 2021/02/25 14:20:46, Tong Sun <[hidden email]> wrote:

> Hi,
>
> Quick & simple question, how to stop the jsr223 script from reaching
> the following processing code (B), return, exit, or ...?
>
> if (A) exit
> B
>
> I just  want the jsr223 script not to process the following code, B,
> not to stop the whole thread execution, of which it's the only hits
> I've found from the internet so far.
>
> thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]