-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_spog_tests.sh
95 lines (87 loc) · 2.45 KB
/
run_spog_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /usr/bin/env bash
set -e
#----------------- GLOBAL VARIABLES -----------------
TEST_RESULTS_DIR="results"
TEST_DIR="tests"
#--------------------- FUNCTIONS --------------------
arg_handle(){
CLI_ARGS=$@
ARGS_LIST="a:u:p:hr:t:"
while getopts $ARGS_LIST opt; do
case "$opt" in
a)
export TRUST_APP_URL="$OPTARG"
;;
u)
export TRUST_USER_NAME="$OPTARG"
;;
p)
export TRUST_USER_PASSWORD="$OPTARG"
;;
r)
TEST_RESULTS_DIR="$OPTARG"
;;
t)
TEST_DIR="$OPTARG"
;;
h)
help $OPTARG
exit 0
;;
:)
echo "Option $OPTARG requires an option" >&2
exit 1
;;
\?)
echo "Invalid option: $OPTARG" >&2
help $OPTARG
exit 1
;;
esac
done
}
set_env(){
VENV_DIR="${PWD}/venv"
cmd="${VENV_DIR}/bin/playwright --version"
if ! $cmd &> /dev/null; then
echo "Creating virual environment....."
python3 -m venv ${VENV_DIR}
source ${VENV_DIR}/bin/activate
${VENV_DIR}/bin/python3 -m pip install .
playwright install
fi
}
results_dir(){
RESULTS="${PWD}/${TEST_RESULTS_DIR}/testrun-$(date +%Y-%m-%d-%H-%M-%S)"
mkdir -p $RESULTS
}
help(){
echo ""
echo "Execute SPoG UI tests"
echo ""
echo " To begin with, the user might need to configure and install the dependencies."
echo "The information required to login to the application can be provided through flags."
echo ""
echo "Usage:"
echo " sh run_spog_tests.sh [options]"
echo ""
echo "Examples:"
echo "sh run_spog_tests.sh -a https://staging.trustification.dev/ -u test -p user@123"
echo ""
echo "Options:"
echo " -a: Application URL"
echo " -u: Username"
echo " -p: Password"
echo " -t: Directory contains tests, defaults to /tests directory"
echo " -r: Directory for results, defaults to /results directory"
echo ""
}
if [ "$#" -eq 0 ]; then
help
exit 1
fi
arg_handle "$@"
set_env
results_dir
pytest $TEST_DIR --headed --html $RESULTS/report.html --application $TRUST_APP_URL --username $TRUST_USER_NAME --password $TRUST_USER_PASSWORD
set +e