How can I go about running tests/controllers based on random weight? For instance, have two tests, one with a weight of 25%, the other with 50%. The one with 50 should run t
I achieved this by creating a Switch Controller with the following switch value:
${__javaScript( var s="001"; new Number(s.charAt( Math.floor(Math.random()*s.length) )) )}
The javascript selects a random character from the string s
and converts it to a number. So in the example above, 0 would be selected twice as often as 1, and the weightings can be altered by adding/removing characters from the string.
I used a String and not an Array was because the javascript version used by my version of JMeter appeared to not support array literals, so this made it a bit less verbose.