title: "When /^I (run|try) ([^]+)`$/"
post_status: publish
comment_status: open
taxonomy:
category:
- wp-cli-handbook
post_tag:
- Behat Steps
- References
- Repos
When /^I (run|try) ([^]+)`$/
运行或尝试执行给定的命令。
用法
run 期望退出码为 0,而 try 允许非零退出码。
因此,如果使用 run 且命令出错,该步骤将失败。
Scenario: 我的示例场景
When I run `wp core version`
Then STDOUT 应包含:
"""
6.8
"""
Scenario: 我的另一个场景
When I try `wp i18n make-pot foo bar/baz.pot`
Then STDERR 应包含:
"""
Error: Not a valid source directory.
"""
And 返回码应为 1
Behat 步骤文档在每次发布时从 WP-CLI 代码库生成。如需改进,请提交拉取请求。
相关
- When /^I launch in the background `([^`]+)`$/ - 在后台启动给定的命令。
- When /^I (run|try) `([^`]+)` from '([^\s]+)'$/ - 在子目录中运行或尝试执行给定的命令。
- When /^I (run|try) the previous command again$/ - 再次运行或尝试执行上一个命令。