我正在将命令行参数传递给 gatling 脚本。
这可以在 Windows 操作系统中运行并执行我的测试:
set JAVA_OPTS="-DuserCount=2 -DflowRepeatCount=3 -DdefinitionId=102168 -DtestServerUrl=https://someURL -DenvAuthenticationHeaderFromPostman="Basic UWRZm9aGwsxFsB1V7RXK0OlB5cmZvcm1hbmNldGVzdDE="
它工作并接受传递的输入
**********************INPUT*************************************
User Count ====>> 2
Repeat Count ====>> 3
Definition ID ====>> 102168
Environment URL ====>> https://someURL
Authentication Header ====>> Basic UWRZm9aGwsxFsB1V7RXK0OlB5cmZvcm1hbmNldGVzdDE=
***********************************************************
我想在 Linux 系统上做同样的事情。 如果我在 Linux 中使用此命令,则它会抛出错误或将 Null 或 Binary 值作为输入 (通过 ./gatling.sh 传递参数)
JAVA_OPTS="-DuserCount=2 -DflowRepeatCount=3 -DdefinitionId=102168 -DtestServerUrl='https://someURL' -DenvAuthenticationHeaderFromPostman='Basic UWRZm9aGwsxFsB1V7RXK0OlB5cmZvcm1hbmNldGVzdDE='" ./gatling.sh
给出这个错误,
GATLING_HOME is set to /opt/gatling-charts-highcharts-2.0.3 Error: Could not find or load main class UWRZm9aGwsxFsB1V7RXK0OlB5cmZvcm1hbmNldGVzdDE='
这里的问题是 -DenvAuthenticationHeaderFromPostman='Basic UWRZm9aGwsxFsB1V7RXK0OlB5cmZvcm1hbm=' 参数中给出的空间
。
解决方案是什么?
最佳答案
问题是 $JAVA_OPTS 变量可能没有被引号包围。看到这个问题:Passing a space-separated System Property via a shell script doesn't work
The gatling guys clearly forgot to do that .
我会提交错误和/或只编辑 gatling.sh
。
理想情况下,尽管您可能只想考虑查看 Gatling 是否采用属性文件或 some other way to configure .
关于linux - 在 Linux 中的 JAVA_OPTS 中传递带空格的参数时抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38349325/