-
Notifications
You must be signed in to change notification settings - Fork 23
/
run-tests.sh
executable file
·71 lines (53 loc) · 1.62 KB
/
run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# set of constants to colorize output
FAILED_OUT="\033[0;31m"
YELLOW_OUT="\033[1;33m"
NONE_OUT="\033[0m"
pretty-output() {
t="$@xxxx"
c=${replace:--}
echo -e ${t//?/$c}
echo -e "$c $@ $c"
echo -e ${t//?/$c}
}
helper() {
echo "Tool allows to simplify run of automated tests for POM sample project."
echo ""
echo "Available actions:"
echo -e " - smoke\t\t run automated smoke tests"
echo -e " - unittest\t\t run automated unittest tests"
echo -e " - all\t\t\t run all automated tests"
echo -e " - help\t\t\t display help message"
echo ""
echo -e "Note:\t\t help will be provided in case of no input parameters"
}
raise-error-message() {
echo -e "Invalid ${FAILED_OUT}$1${NONE_OUT} parameter is provided!"
echo -e "Please use ${YELLOW_OUT}smoke${NONE_OUT} or ${YELLOW_OUT}unit${NONE_OUT} or ${YELLOW_OUT}help${NONE_OUT} keys as a flag."
exit 1
}
clear-trash() {
local trash='.pytest_cache'
[[ -d "$trash" ]] && echo "removing ${trash} testing trash" && rm -rf ${trash} && echo "environment is cleared"
}
unit() {
pytest -m unit
}
smoke() {
pytest -m smoke
}
all() {
pytest
}
run-tests() {
local arg=$1
if [[ ${arg} == "smoke" ]] || [[ ${arg} == "unit" ]];
then pretty-output "Running ${arg} suite" && pytest -m "${arg}"; clear-trash
elif [[ ${arg} == "all" ]]
then pretty-output "Running ${arg} suite" && pytest; clear-trash
elif [[ $# -eq 0 ]] || [[ ${arg} == "help" ]] || [[ ${arg} == "--help" ]] || [[ ${arg} == "-h" ]]
then helper
else raise-error-message "${arg}"
fi
}
run-tests "$1"