简体   繁体   中英

Groovy script in JMETER

I was trying to add groovy (Groovy 2.4.3) to the JMeter 2.13.

I am placing all the %groovy_home%/lib/ .jars in %java_home%/lib/ext/groovy-lib/ .jar

I added the classpath in jmeter.property file (search_paths=/lib/ext/groovy-lib)

The problem is after starting JMeter, I am able to use Groovy in BSF elements (assertions, Samplers etc) but the JSR223 elements (assertions, samplers etc) are not showing the Groovy script language option.

BSF显示Groovy

JSR223缺少Groovy

Any help would be valuable Thanks

The simplest and easiest way to get groovy engine up and running is:

  1. Download the latest version of groovy-all.jar from Maven
  2. Drop it to the /lib folder of your JMeter installation. /lib/ext folder is actually for JMeter core and extensions)
  3. Restart JMeter if it's running (jar pickup process is not dynamic, it is also applicable to any other libraries like Jmeter Plugins , JUnit tests , user.properties file change, etc.)
  4. After restart you should see groovy along with the .jar version in parentheses

You must use user.classpath and groovy-all-xxx.jar

List of paths that JMeter will search for utility and plugin dependency classes. Use your platform path separator (as per System Property " path.separator ") to separate multiple paths. A path item can either be a jar file or a directory. Any jar file in such a directory will be automatically included, jar files in sub directories are ignored. The given value is in addition to any jars found in the lib directory. All entries will be added to the class path of the system class loader and also to the path of the JMeter internal loader. Paths with spaces may cause problems for the JVM

So it should be:

user.classpath=/lib/ext/groovy-lib/groovy-all-xxx.jar

You can also install utility Jar files in $JAVA_HOME/jre/lib/ext, or you can set the property user.classpath in jmeter.properties

Note that setting the CLASSPATH environment variable will have no effect. This is because JMeter is started with "java -jar", and the java command silently ignores the CLASSPATH variable, and the -classpath/-cp options when -jar is used. [This occurs with all Java programs, not just JMeter.]

According to this , but for me this made the magic : Just edit user.classpath property in jmeter.properties.

user.classpath="YOUR-GROOVY-HOME-DIR"/lib

Surprisingly using $GROOVY_HOME did not work and I had to mention the groovy home path instead of referring to system environment variable, and as @ubik-load-pack mentioned if you need more items to be added to this property, use your operating system classpath separator character( Linux=":", Windows=";" )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM