-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrunAllTests.sh
181 lines (154 loc) · 4.27 KB
/
runAllTests.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
set -x
cd "$(dirname "$0")/.."
root=$(pwd)
out=$(realpath out/"$(date "+%Y%m%d-%H%M%S")"-runAllTests.log)
report=$root/report/build/libs/report-1.0-SNAPSHOT-all.jar
branch="$(git branch --show-current)"
stage="local"
# pass results to bigquery
transmit=false
# process arguments
while getopts "ts:" o; do
case "${o}" in
t)
transmit=true
;;
s)
stage=$OPTARG
;;
*)
echo "Usage: bash runAllTests.sh [-t] [-s \"\$stage\"]"
;;
esac
done
# In the context of processing command-line arguments with getopts, shift $((OPTIND-1)) is used to remove all the processed options and their corresponding arguments from the positional parameters.
shift $((OPTIND - 1))
build-reporting-lib() {
if ! test -f "$report"; then
(
cd report
./gradlew clean shadowJAR
)
fi
}
report-results() {
java -jar "$report" -u "$USER" -b "$branch" -t $transmit "$@"
}
tee-to-out() {
tee -a $out
}
unit-tests() {
(
cd bff
./gradlew clean test | tee-to-out
report-results build/test-results/test -l local -s bff -i isolated --src bff-unit-tests | tee-to-out
)
(
cd todo-service
./gradlew clean test | tee-to-out
report-results build/test-results/test -l local -s todo-service -i isolated --src todo-service-unit-tests | tee-to-out
)
(
cd single-page-application
rm junit.xml || true
npm run test-ci | tee-to-out
report-results . -l local -s single-page-application -i isolated --src single-page-application-component-tests | tee-to-out
rm cypress/TEST-*.xml || true
npx cypress run --component --reporter junit --reporter-options "mochaFile=cypress/TEST-[hash].xml,toConsole=true,includePending=true,jenkinsMode=true" | tee-to-out
report-results ./cypress -l local -s single-page-application -i isolated --src single-page-application-cypress-component-tests | tee-to-out
)
}
services-up() {
docker compose -f docker-compose.local.yml up -d --build
}
services-down() {
docker compose -f docker-compose.local.yml down
}
wait-for-services() {
./bin/wait-for-it.sh localhost:3000
./bin/wait-for-it.sh localhost:8080
}
supertest() {
(
cd system-tests/supertest
if test "$stage" = "local"; then
npm run test-local
fi
if test "$stage" = "prod"; then
npm run test-prod
fi
report-results . -l "$stage" -s system -i integrated-mocked-3rd-party --src supertest-tests
)
}
playwright-js() {
(
cd system-tests/playwright-js
if test "$stage" = "local"; then
npm run test-local
fi
if test "$stage" = "prod"; then
npm run test-prod
fi
report-results . -l "$stage" -s system -i integrated-mocked-3rd-party --src playwright-js
)
}
postman() {
(
cd system-tests/postman
rm newman/*.xml || true
if test "$stage" = "local"; then
npm run test
fi
if test "$stage" = "prod"; then
npm run test-prod
fi
report-results ./newman -l "$stage" -s system -i integrated-mocked-3rd-party --src postman-collection
)
}
serenity-rest-assured() {
(
cd system-tests/serenity-bdd-screenplay-rest-assured
if test "$stage" = "local"; then
./gradlew clean test -DHOST=http://localhost:8080
fi
if test "$stage" = "prod"; then
./gradlew clean test -DHOST=https://bff-fg5blhx72q-ey.a.run.app/health
fi
report-results build/test-results/test -l "$stage" -s system -i integrated-mocked-3rd-party --src serenity-rest-assured-tests
)
}
serenity-cucumber-browser() {
(
cd system-tests/serenity-bdd-cucumber
if test "$stage" = "local"; then
./mvnw clean verify -DHOST=http://localhost:3000
fi
if test "$stage" = "prod"; then
./mvnw clean verify -DHOST=https://single-page-application-fg5blhx72q-ey.a.run.app/
fi
report-results target/failsafe-reports -l "$stage" -s system -i integrated-mocked-3rd-party --src serenity-cucumber-browser-tests
)
}
system-tests() {
postman
supertest
serenity-rest-assured
playwright-js
serenity-cucumber-browser
}
build-reporting-lib
if test "$stage" = "local"; then
unit-tests
services-up
wait-for-services
system-tests
services-down
elif test "$stage" = "prod"; then
system-tests
else
echo "unsupported stage: $stage"
exit 1
fi
RED='\033[0;31m'
cat "$out" | grep "TestResult" | grep -vE "success|skipped" | xargs echo -e $RED