空手道选手->空手道罐:命令行参数设置问题 [英] Karate Runner -> karate jar : Command line args settings issue
问题描述
我正在使用Visual Studio代码,并且已安装Karate Runner插件.将karate-config.js与独立jar(karate.jar)结合使用.我试图在空手道跑步者的VS代码中为空手道跑步者配置空手道->空手道jar:命令行参数为"java -Dkarate.config.dir = test/resources/-cp karate.jar com.intuit.karate.Main"但会引发类似
I am using Visual Studio code and Karate Runner plugin is installed. Using karate-config.js with standalone jar (karate.jar). I have tried to configure in karate runner settings in VS code for Karate Runner -> karate jar : Command line args as "java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main" but it throws an exception like
执行任务:java -Dkarate.config.dir = test/resources/-cp karate.jar com.intuit.karate.Main"d:\ GitHub \ KarateTestFramework \ test \ features \ script \ all_users.feature:9";<
Executing task: java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main "d:\GitHub\KarateTestFramework\test\features\script\all_users.feature:9" <
错误:无法找到或加载主类.config.dir = test.resources.终端进程"C:\ WINDOWS \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe-命令java -Dkarate.config.dir = test/resources/-cp karate.jar com.intuit.karate.Main" d:\ GitHub \ KarateTestFramework \ test \ features \ script \ all_users.feature:9""以退出代码终止:1.
Error: Could not find or load main class .config.dir=test.resources. The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main "d:\GitHub\KarateTestFramework\test\features\script\all_users.feature:9"" terminated with exit code: 1.
终端将被任务重用,按任意键将其关闭.
Terminal will be reused by tasks, press any key to close it.
我还尝试了-Dkarate.config.dir = D:/GitHub/KarateTestFramework/test/resources的完整路径,但也没有用.
Also, I have tried full path for -Dkarate.config.dir=D:/GitHub/KarateTestFramework/test/resources but didn't work either.
请指导我解决此问题.
推荐答案
@ChandramohanRamabadran,我尝试在系统上复制该问题.我相信这不是错误!
@ChandramohanRamabadran, I tried to replicate the issue on my system. I believe it's not a bug!
之所以发生这种情况,是因为您的VisualStudio使用的是PowerShell,而不是CMD.我相信您可能已经错过了在安装空手道后更改VisualStudio的默认外壳.尝试将默认Shell从PowerShell更新为CMD ;那你应该很好.
It's happening because your VisualStudio is using PowerShell instead of CMD. I believe you might have missed the step to change the default shell of VisualStudio after installing Karate. Try updating the default shell from PowerShell to CMD; then you should be good.
但是,如果您仍然想使用PowerShell,请更新命令
However, if you still want to use PowerShell, then update the command
java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main
到
java `-Dkarate.config.dir`=test/resources/ -cp karate.jar com.intuit.karate.Main
有关此问题的更多背景信息:PowerShell具有更标准的规则来解析不同于CMD的系统属性参数.在PowerShell命令中,参数名称始终以连字符开头.连字符告诉PowerShell命令中的项目是参数名称.
More context over the issue: PowerShell has a more standard rule to parse system-properties parameters which are different from CMD. In a PowerShell command, the parameter names always begin with a hyphen. The hyphen tells PowerShell that the item in the command is a parameter name.
在这里,我们将参数传递为 -Dkarate.config.dir
,PowerShell将参数名称标签视为 -Dkarate
,而不是 -Dkarate.config.dir
;因此是错误.
Here, we are passing the parameter as -Dkarate.config.dir
, PowerShell sights the parameter name-tag as -Dkarate
and not -Dkarate.config.dir
; hence the error.
这篇关于空手道选手->空手道罐:命令行参数设置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!