Search code examples
jmetercommand-promptbeanshelljsr223

How to read JMeter Test Cmd Line Parameters from JSR223/Beanshell


I have wrote a JMeter test and I want to run it in Command Line with some parameters, let's say ThreadNumber.

How do I read it in JSR223/BeanShell?


Solution

  • Send property in command line using -J which adds new property

     -JthreadNum=100
    

    Inside Thread Group use the value using __P function in Number of Users(threads) field

     ${__P(threadNum)}
    

    simplified property function which is intended for use with properties defined on the command line.

    Use props to get properry in JSR223/BeanShell

      props.get("threadNum")
    
    • Note you may set ramp up same as thread number property

    Start with Ramp-up = number of threads and adjust up or down as needed.