Beanshell type of variable assertion on Jmeter

295 Views Asked by At

I want to validate some variable types from a response on Jmeter by using Beanshell Assertions like so

(C# example)

if(foo typeof bar){
   //stuff
}

I've googled and searched on beanshell documentation but i can't find anything close to this.

Is there a way to do something simmilar?

Thanks.

1

There are 1 best solutions below

1
Dmitri T On BEST ANSWER

Are you looking for an instanceof operator?

foo ="1";

if (foo instanceof String) {
   log.info("It's a string");
}

foo = 1;

if (foo instanceof bsh.Primitive) {
   log.info("It's a primitive");
}

enter image description here

Also be aware that starting from JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language so it worth migrating to JSR223 Assertion and Groovy language