You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Erez Naim <er...@theneura.com> on 2015/08/18 14:16:33 UTC

BeanShell post processor or Beanshell assertion

Hello all,

 

I am trying to fail in purpose a sampler in case it wont pass several
criteiras I have defined before. 

 

I have this script (beanshell post processor):

 

if(i==4){

 


 
msg = getMessage(item,i,suggestions);

 
System.out.println(msg+" "+ i);

 
if(!msg.equals("Hi, I'm about to leave work. Need anything?")){

 
System.out.println("Test failed");

 
}

 
}

 

 

I want to fail the sampler in case it will get into the second if statement
and will prompt to console the fail message (additionally I want to fail the
sampler itself as a result).

 

Thanks,

 


Erez Naim  |  QA Lead  |
<http://www.linkedin.com/profile/view?id=34323263>
<http://www.theneura.com/vCards/gilad.vcf>
<http://twitter.com/#!/giladmeiri/>   




EL AL 2 Street | Herzliya  
mobile (+972) 50 9 555 686 | fax (408) 689.1366 | skype erez.neura

 


 <http://www.theneura.com/> website  |   <http://www.startupbitz.com/> blog
|   <https://twitter.com/intent/user?screen_name=theneura> twitter  |
<http://goo.gl/maps/ZRkg5> map    

 

 


Re: BeanShell post processor or Beanshell assertion

Posted by sebb <se...@gmail.com>.
The documentation for
http://jmeter.apache.org/usermanual/component_reference.html#BeanShell_Assertion
says

   - Failure - boolean; read-write; used to set the Assertion status
   - FailureMessage - String; read-write; used to set the Assertion message



On 18 August 2015 at 13:16, Erez Naim <er...@theneura.com> wrote:

> Hello all,
>
>
>
> I am trying to fail in purpose a sampler in case it wont pass several
> criteiras I have defined before.
>
>
>
> I have this script (beanshell post processor):
>
>
>
> if(i==4){
>
>
>
>
>
>
> msg = getMessage(item,i,suggestions);
>
>
>
> System.out.println(msg+" "+ i);
>
>
>
> if(!msg.equals("Hi, I'm about to leave work. Need anything?")){
>
>
>
>                                                 System.out.println("Test
> failed");
>
>
> }
>
>
> }
>
>
>
>
>
> I want to fail the sampler in case it will get into the second if
> statement and will prompt to console the fail message (additionally I want
> to fail the sampler itself as a result).
>
>
>
> Thanks,
>
>
>
> Erez Naim  |  QA Lead  |   [image: LinkedIn]
> <http://www.linkedin.com/profile/view?id=34323263>  [image: vCard]
> <http://www.theneura.com/vCards/gilad.vcf>  [image: Twitter]
> <http://twitter.com/#!/giladmeiri/>
>
> [image: cid:image004.png@01D01E1B.5F153500]
>
> EL AL 2 Street | Herzliya
> mobile (+972) 50 9 555 686 | fax (408) 689.1366 | skype erez.neura
>
>
>
> website <http://www.theneura.com/>  |  blog <http://www.startupbitz.com/>
>  |  twitter <https://twitter.com/intent/user?screen_name=theneura>  |  map
> <http://goo.gl/maps/ZRkg5>
>
>
>
>
>

Re: BeanShell post processor or Beanshell assertion

Posted by Bob <b....@gmail.com>.
If you want to mark sampler as failure use:

Failure = true;
FailureMessage = "Fail text";

if vice versa use:

SampleResult.setResponseOK();

On 18/08/15 17:16, Erez Naim wrote:
>
> Hello all,
>
> I am trying to fail in purpose a sampler in case it wont pass several 
> criteiras I have defined before.
>
> I have this script (beanshell post processor):
>
> if(i==4){
>
> msg = getMessage(item,i,suggestions);
>
> System.out.println(msg+" "+ i);
>
> if(!msg.equals("Hi, I'm about to leave work. Need anything?")){
>
> System.out.println("Test failed");
>
> }
>
> }
>
> I want to fail the sampler in case it will get into the second if 
> statement and will prompt to console the fail message (additionally I 
> want to fail the sampler itself as a result).
>
> Thanks,
>
> Erez Naim |  QA Lead  | LinkedIn 
> <http://www.linkedin.com/profile/view?id=34323263>vCard 
> <http://www.theneura.com/vCards/gilad.vcf>Twitter 
> <http://twitter.com/#%21/giladmeiri/>
>
> cid:image004.png@01D01E1B.5F153500
>
> EL AL 2 Street | Herzliya
> mobile (+972) 50 9 555 686 | fax (408) 689.1366 | skype erez.neura
>
> website <http://www.theneura.com/> |blog <http://www.startupbitz.com/> 
> |twitter <https://twitter.com/intent/user?screen_name=theneura> |map 
> <http://goo.gl/maps/ZRkg5>
>


Re: BeanShell post processor or Beanshell assertion

Posted by Pratapi Hemant Patel <he...@gmail.com>.
Use *prev.setSuccessful(false); *in the second if statement.

Thanks and Regards
Hemant
9810752184 / 9013982184

On Tue, Aug 18, 2015 at 5:46 PM, Erez Naim <er...@theneura.com> wrote:

> Hello all,
>
>
>
> I am trying to fail in purpose a sampler in case it wont pass several
> criteiras I have defined before.
>
>
>
> I have this script (beanshell post processor):
>
>
>
> if(i==4){
>
>
>
>
>
>
> msg = getMessage(item,i,suggestions);
>
>
>
> System.out.println(msg+" "+ i);
>
>
>
> if(!msg.equals("Hi, I'm about to leave work. Need anything?")){
>
>
>
>                                                 System.out.println("Test
> failed");
>
>
> }
>
>
> }
>
>
>
>
>
> I want to fail the sampler in case it will get into the second if
> statement and will prompt to console the fail message (additionally I want
> to fail the sampler itself as a result).
>
>
>
> Thanks,
>
>
>
> Erez Naim  |  QA Lead  |   [image: LinkedIn]
> <http://www.linkedin.com/profile/view?id=34323263>  [image: vCard]
> <http://www.theneura.com/vCards/gilad.vcf>  [image: Twitter]
> <http://twitter.com/#!/giladmeiri/>
>
> [image: cid:image004.png@01D01E1B.5F153500]
>
> EL AL 2 Street | Herzliya
> mobile (+972) 50 9 555 686 | fax (408) 689.1366 | skype erez.neura
>
>
>
> website <http://www.theneura.com/>  |  blog <http://www.startupbitz.com/>
>  |  twitter <https://twitter.com/intent/user?screen_name=theneura>  |  map
> <http://goo.gl/maps/ZRkg5>
>
>
>
>
>