Problem statement. Set of transactions(1000+) and need to call or reuse(without duplicating in different if/switch controllers) by invoking from the Beanshell or JSR233.
In SoapUI we have groovy script option to break sequential execution and divert control to any request using the below command.
if( Math.random() > 0.5 )
testRunner.runTestStepByName( "Request 1")
else
testRunner.runTestStepByName( "Request 2")
// do something else
....
Same functionality available in Loadrunner(Run time setting with different action) and neoload too.
Do we have any built-in objects or function to execute by transaction or Sampler name from JSR223/BeanShell without using if/while/switch controller ?
For Example:
In script 10 transactions are there and to use same script for different scenario by setting a JMeter property during execution through Jenkins or command prompt .
__P(Flow,RoomBooking)
Then from JSR233 /beanshell sampler
if(Flow=="RoomBooking"){
invoke Login
invoke BookRoom
invoke Logout
} else if(Flow=="RoomBookingNBookItinerary")
invoke Login
invoke BookRoom
invoke BookItinerary
invoke Logout
}else if(Flow=="RoomBookingNcancel")
invoke Login
invoke BookRoom
Invoke ParkTicket
invoke CancelRoom
invoke Logout
}Like different flows with different thread and throughput
In this case I can mix and match different flows and and reuse same script for different flow. This would help to reduce script rework effort during application changes.
You are right, JMeter doesn't have JSR 223 Logic Controller at all,
I think that it can help changing also the if controller,
I suggest you open an enhancement to JMeter product (choose Severity: enhancement)
EDIT
There's a new Bug 61711 - Add JSR223 Logic Controller you can vote on.