我们有一个脚本,看起来像这样:

#!/bin/bash
for cookbook in $cookbooks; do
    cd /path/to/$cookbook
    kitchen test;
    # Log whether the test failed or passed
done;

# Print number of tests passed and number of tests failed


如何确定我的kitchen test是通过还是失败?

最佳答案

您可以检查kitchen test命令的退出状态,并增加计数器,例如:

#!/bin/bash
let failed=0
let passed=0

for cookbook in $cookbooks; do
  cd /path/to/$cookbook
  kitchen test;

  if [ $? -ne 0 ]
  then
     failed=$((failed + 1))
  else
    passed=$((passed + 1))
  fi
done;

echo "There was $passed passed and $failed failed tests."

关于testing - 确定测试厨房测试是否通过或失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29242357/

10-12 04:53