Created
March 27, 2020 03:11
-
-
Save levantAJ/84b4d81aecb10b444ae95b2aad13ad36 to your computer and use it in GitHub Desktop.
Generate Test Coverage by Feature (Folder) with Slather
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This file to facilitate getting test coverage percentage | |
# | |
# How to use: | |
# 1. For all test cases: | |
# bash test-coverage.sh | |
# | |
# 2. For test cases belong to a feature: | |
# bash test-coverage.sh {Feature_Folder_Name} | |
# Feature_Folder_Name: The name of the folder under YourProject. | |
# e.g Authentication, Home, Settings, ... | |
YELLOW=`tput setaf 3` | |
RESET=`tput sgr0` | |
BOLD=`tput bold` | |
GREEN=`tput setaf 2` | |
RED=`tput setaf 1` | |
echo -e "${YELLOW}Make sure you run test successfully on Xcode before run this script!${RESET}" | |
if [ "$1" ]; then | |
feature=$1 | |
echo -e "Collecting test reports for ${BOLD}${GREEN}${feature}${RESET}..." | |
# Ignore Libraries | |
ignore_list="--ignore \"Pods/*\"" | |
binaries="--binary-basename YourProject" | |
prefixPath="./YourProject/" | |
for d in ./ShopBack/*; do | |
folder=${d#$prefixPath} | |
if [ "$feature" != "$folder" ] | |
then | |
ignore_list=$ignore_list" -i \"YourProject/$folder/*\"" | |
fi | |
done | |
# Combine ignore list and binaries to final slather command to get slather report. | |
slather_cmd="slather coverage -s "$binaries" "$ignore_list" --scheme YourSchemeName --workspace YourWorkspaceName.xcworkspace YourProjectName.xcodeproj" | |
eval $slather_cmd | |
else | |
slather_cmd="slather coverage -s --scheme YourSchemeName --workspace YourWorkspaceName.xcworkspace YourProjectName.xcodeproj" | |
echo "Collecting test reports for ${BOLD}${RED}all projects${RESET}..." | |
eval $slather_cmd | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment