Skip to content

Instantly share code, notes, and snippets.

@legovaer
Created April 8, 2015 14:31
Show Gist options
  • Save legovaer/4d1c0e1dc5c0c0afbf0d to your computer and use it in GitHub Desktop.
Save legovaer/4d1c0e1dc5c0c0afbf0d to your computer and use it in GitHub Desktop.
Behat Scenario overview
#!/bin/bash
# Bash script that will give you a overview of all Scenario's inside your
# features folder. By default, the folder "features/" will be analyzed.
# If your feature files are located somewhere else, just pass the folder as an argument.
green='\e[30;48;5;82m'
gold='\e[38;5;208m'
NC='\033[0m'
FOLDER="features/"
if [ ! -z "$1" ]; then
FOLDER=$1
fi
for i in $(find $FOLDER -name '*.feature'); do
OUTP=`cat $i | grep -nw 'Scenario:\|Scenario Outline:'`
AMOUNT=`echo "$OUTP" | wc -l`
echo -e "${green} $i -- ${AMOUNT} Scenario(s) ${NC}"
if [ ! -z "$OUTP" ]; then
while read -r line; do
LN=`echo $line | cut -d : -f 1`
TAGLN=`expr $LN - 1`
TAGS=$(sed -n ${TAGLN}p $i | sed 's/^[ \t]*//')
TAGOUTP=''
while read -r tag; do
TAGOUTP="${TAGOUTP} ${tag}"
done <<< "$TAGS"
if [ ! -z "$TAGOUTP" ]; then
TAGOUTP="(${gold}$TAGOUTP${NC})"
fi
SCEN=`echo $line | sed 's/[0-9]*://' | sed 's/^[ \t]*//'`
echo -e "${green}$LN:${NC}$SCEN"
done <<< "$OUTP"
echo -e "\n"
fi
done
@legovaer
Copy link
Author

legovaer commented Apr 8, 2015

Plan was to add an overview of tags that were used in that scenario. That was kind of buggy. I'll add it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment