在我的测试计划中,我有以下脚本,
import groovy.json.JsonSlurper;
def completeFetchedStudyNameFromResponse = [];
1. upto(vars.get('studyNameFetched_matchNr') as int, {
index ->
completeFetchedStudyNameFromResponse.add(vars.get('studyNameFetched_' + index));
});
String tempToBeExcludedStudyName = vars.get('excludeStudyName');
def toBeDeleteStudy = [];
def studyNameNeedToExcludeFromDeletion = new JsonSlurper().parseText(tempToBeExcludedStudyName);
def filteredStudyName = completeFetchedStudyNameFromResponse.findAll {
studyName ->
studyNameNeedToExcludeFromDeletion.every {
keywords ->
studyName.contains(keywords)
}
}
def bdConverter = new JsonSlurper();
def responseBDTemp = prev.getResponseDataAsString();
def responseBD = bdConverter.parseText(responseBDTemp);
def resultStudyUUIDCollector = [];
def parsedResultBD = responseBD.accounts;
filteredStudyName.each { studyNameFew ->
resultStudyUUIDCollector.add(responseBD.accounts.find { account -> account.name == studyNameFew }.uuid)
}
vars.putObject("myList", resultStudyUUIDCollector);
这个脚本在JMeter 5.5和Java 17中运行得很好,但是当我在JMeter 5.4和Java 1.8中运行这个脚本时,出现了以下错误:
2023-06-16 11:34:58,180 ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, StudyName_Processer
javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unable to resolve class groovy.json.JsonSlurper
有没有什么方法可以在不升级的情况下用较低版本的Java运行相同的程序?
1条答案
按热度按时间y3bcpkx11#
你可以用较低版本的Java运行相同的代码,而不必降级,因为相同的代码应该可以很好地工作。
您得到的错误意味着您的JMeter5.4安装被破坏了,因为有人不是很聪明,或者是意外地从JMeter的“lib”文件夹中删除了groovy-json-3.0.5.jar
因此,要么下载groovy-json-3.0.5.jar并将其放入JMeter 5.4安装的“lib”文件夹,要么完全下载reinstall JMeter,因为谁知道还缺少什么。
根据JMeter最佳实践you should always be using the latest version of JMeter,它包含bug修复、新功能和性能改进。特别是JMeter 5.4受到Log4Shell的影响,因此考虑将其升级到JMeter 5.5是有意义的,因此您的JMeter版本将相同。