如何在Windows上的shell / bash脚本中运行Robot Framework的`robot`命令?

作为用户,我想通过一些命令行选项执行Robot Framework的robot命令。我将所有内容放在脚本中,以避免每次都重新键入长命令-请参见下面的示例。在Linux和Mac OS上,我可以从任何终端仿真器(即

)执行此脚本
# Linux
. run_local_tests.sh

# Mac OS
./run_local_tests.sh

在Windows上,打开了与.sh文件类型关联的应用程序(VSCode编辑器),而不是执行robot命令,或者返回了类似robot: command not found的错误

# Windows
.\run_local_tests.sh
# OR
run_local_tests.sh
# OR
bash run_local_tests.sh
  

shell脚本-文件名:run_local_tests.sh

#!/bin/bash
# Set desired loglevel: NONE (less details),INFO,DEBUG,TRACE (most details) 
export LOG_LEVEL=TRACE
# RUN CONTRIBUTION SERVICE TESTS
robot -i CONTRIBUTION -e circleci \
  --outputdir results \
  --log NONE \
  --report NONE \
  --output XML/CONTRIBUTION.xml \
  --noncritical not-ready \
  --flattenkeywords for \
  --flattenkeywords foritem \
  --flattenkeywords name:_resources.* \
  --loglevel $LOG_LEVEL \
  --name CONTRI \
  robot/CONTRIBUTION_TESTS/
  • 将脚本从.sh重命名为.bat并没有帮助:(
  • 输入bash,然后激活venv并调用脚本不起作用

还有哪些其他选项(无需安装Cygwin等其他工具)?

tianlong253 回答:如何在Windows上的shell / bash脚本中运行Robot Framework的`robot`命令?

我实际上是在反方向回答相同的问题(如何在我的计算机上以.sh触发/运行它们)。看起来我们可能会互相帮助。 8)

我相信这是您要寻找的: 您的文件将为 run_local_tests.bat

内容:

@echo off
cd C:\path\to\robot\project
call robot -d relative/path/to/test/output/dir relative/path/to/run_local_tests.bat

当然,您也可以在调用中使用其他任何有效的robot cli语法。您可能也必须使其可执行。我不确定。

本文链接:https://www.f2er.com/3122622.html

大家都在问