Search code examples
javaintellij-ideajmeterbeanshelljsr223

JMeter external JSR223 java edited in Intellij


I'd like to reach that point where I have a development environment with the following attributes:

  • JMeter tests consist of JSR 233 scripts mainly
  • JSR 233 scripts are written in Java
  • I can edit the java code in IntelliJ
  • the project is a maven project

So far I could do everything from the list above except IntelliJ support. So, I add a JSR 233 PreProcessor script to the test using JMeter GUI, I setup the script path. When I create the .java file and start to edit in Intellij following examples IntelliJ gets crazy, since the code is not enclosed in a class {}. As a result I can't leverage on IntelliJs capabilities and great support in java.

Is there any way to configure IntelliJ to support these script files?

I double checked how the example Java code is stored in the jmx file, and it is not enclosed in a class {}.

Why not Groovy? you might ask. The reason is that, when I made a mistake in groovy script it doesn't cause build failure, it will give me a runtime error. I consider this not effective enough, however groovy is plan C.

Plan B is all java code gets into an external jar and will be included in minimal groovy script.

I would really appreciate if you could help with answers or any articles probably answers my question.


Solution

  • Java scripting code is actually running Beanshell language

    You have BeanShell Box plugin that support your requirement in Intellij

    Adds a BeanShell toolbox allowing you to write snippets of both Java and BeanShell code.

    Benshell file extension is .bsh usually