我在我的一个项目中使用黄瓜JVM。我希望一旦失败就得到一个场景的所有步骤列表。有什么方法可以做到这一点吗?
答案 0 :(得分:0)
一位同事给了我一个bash脚本来寻找步骤
#!/bin/bash
echo "Preparing list of step definitions in directory: $1"
echo "Steps marked with * are unused!"
steps=/tmp/step-definitions.txt
ack-grep "^\s*@(Given|When|Then|And).+" --java -h $1 | sed -r -e 's/^ +@(Given|When|Then|And) *\([^"]*|\) *$//g' -e 's/^"\^?|"$//g' | sort > $steps
used=used-steps.txt
unused=unused-steps.txt
> $used
> $unused
echo "Determine step definition usage:"
while read regex; do
lc=$(find $1 -iname "*.feature" | xargs egrep "$regex" | wc -l)
printf -v lcf "%03d" $lc
if [[ $lc == 0 ]]; then
echo "* $regex"
echo $regex >> $unused
else
echo " $regex"
echo "$lcf uses: $regex" >> $used
fi
done < $steps