简体   繁体   English

在Intellij中编辑的JMeter外部JSR223 java

[英]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 JMeter测试主要由JSR 233脚本组成
  • JSR 233 scripts are written in Java JSR 233脚本是用Java编写的
  • I can edit the java code in IntelliJ 我可以在IntelliJ中编辑java代码
  • the project is a maven project 该项目是一个maven项目

So far I could do everything from the list above except IntelliJ support. 到目前为止,我可以从上面的列表中做所有事情,除了IntelliJ支持。 So, I add a JSR 233 PreProcessor script to the test using JMeter GUI, I setup the script path. 因此,我使用JMeter GUI将JSR 233 PreProcessor脚本添加到测试中,我设置了脚本路径。 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 {} . 当我创建.java文件并开始在Intellij中编辑以下示例时, IntelliJ会变得疯狂,因为代码未包含在class {} As a result I can't leverage on IntelliJs capabilities and great support in java. 因此,我无法利用IntelliJs功能和java中的强大支持。

Is there any way to configure IntelliJ to support these script files? 有没有办法配置IntelliJ来支持这些脚本文件?

I double checked how the example Java code is stored in the jmx file, and it is not enclosed in a class {} . 我仔细检查了示例Java代码如何存储在jmx文件中,并且它没有包含在class {}

Why not Groovy? 为什么不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. 原因是,当我在groovy脚本中犯了一个错误时它不会导致构建失败,它会给我一个运行时错误。 I consider this not effective enough, however groovy is plan C. 我认为这不够有效,但是groovy是计划C.

Plan B is all java code gets into an external jar and will be included in minimal groovy script. 计划B是所有java代码进入外部jar并将包含在最小的groovy脚本中。

I would really appreciate if you could help with answers or any articles probably answers my question. 如果你能帮助解答或任何文章可能回答我的问题,我将非常感激。

Java scripting code is actually running Beanshell language Java脚本代码实际上是运行Beanshell语言

You have BeanShell Box plugin that support your requirement in Intellij 你有BeanShell Box插件,支持你在Intellij中的要求

Adds a BeanShell toolbox allowing you to write snippets of both Java and BeanShell code. 添加BeanShell工具箱,允许您编写Java和BeanShell代码的片段。

Benshell file extension is .bsh usually Benshell文件扩展名通常是.bsh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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