title: "Then /^STDOUT 应是一个包含以下内容的 JSON 数组:$/" post_status: publish comment_status: open taxonomy: category: - wp-cli-handbook post_tag: - Behat Steps - Repos - Data
Then /^STDOUT 应是一个包含以下内容的 JSON 数组:$/
期望 STDOUT 输出有效的 JSON 数组。
用法
当预期数组中缺少某些项目时,会报错。
场景:我的示例场景
当 我运行 `wp plugin list --field=name --format=json`
那么 STDOUT 应是一个包含以下内容的 JSON 数组:
"""
["akismet", "hello-dolly"]
"""
Behat 步骤文档在每次发布时从 WP-CLI 代码库生成。如需改进,请提交拉取请求。
相关
- Then /^the return code should( not)? be (\d+)$/ - 期望上一个命令返回特定的退出码。
- Then /^(STDOUT|STDERR) should( strictly)? (be|contain|not contain):$/ - 检查 STDOUT 或 STDERR 的内容。
- Then /^(STDOUT|STDERR) should be a number$/ - 期望 STDOUT 或 STDERR 是一个数值。
- Then /^(STDOUT|STDERR) should not be a number$/ - 期望 STDOUT 或 STDERR 不是一个数值。
- Then /^STDOUT should be a table containing rows:$/ - 期望 STDOUT 是一个包含给定行的表格。
- Then /^STDOUT should end with a table containing rows:$/ - 期望 STDOUT 以一个包含给定行的表格结尾。
- Then /^STDOUT should be JSON containing:$/ - 期望 STDOUT 包含有效的 JSON 输出。
- Then /^STDOUT should be CSV containing:$/ - 期望 STDOUT 是包含特定值的 CSV。
- Then /^STDOUT should be YAML containing:$/ - 期望 STDOUT 是包含特定内容的 YAML。
- Then /^(STDOUT|STDERR) should be empty$/ - 期望 STDOUT 或 STDERR 为空。
- Then /^(STDOUT|STDERR) should not be empty$/ - 期望 STDOUT 或 STDERR 不为空。
- Then /^(STDOUT|STDERR) should be a version string (<|<=|>|>=|==|=|!=|<>) ([+\w.{}-]+)$/ - 期望 STDOUT 或 STDERR 是一个版本字符串,并与给定版本进行比较。
- Then /^the (.+) (file|directory) should( strictly)? (exist|not exist|be:|contain:|not contain:)$/ - 期望某个文件或目录(不)存在或(不)包含特定内容。
- Then /^the contents of the (.+) file should( not)? match (((\/.+\/)|(#.+#))([a-z]+)?)$/ - 使用正则表达式匹配文件内容。
- Then /^(STDOUT|STDERR) should( not)? match (((\/.+\/)|(#.+#))([a-z]+)?)$/ - 使用正则表达式匹配 STDOUT 或 STDERR。
- Then /^an email should (be sent|not be sent)$/ - 期望发送(或不发送)一封电子邮件。
- Then the HTTP status code should be :code - 期望访问 `http://localhost:8080` 时的 HTTP 状态码。