-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathunit_test.sh
executable file
·77 lines (73 loc) · 2.16 KB
/
unit_test.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
#!/usr/bin/env bash
red=$(tput setaf 1)
green=$(tput setaf 2)
none=$(tput sgr0)
show_help() {
printf "usage: $0 [--help] [--report] [--test] [<path to package>]
Script for running all unit and widget tests with code coverage.
(run from root of repo)
where:
<path to package>
runs all tests with coverage and reports
-t, --test
runs all tests with coverage, but no report
-r, --report
generate a coverage report
(requires lcov, install with Homebrew)
-h, --help
print this message
"
}
run_tests() {
if [[ -f "pubspec.yaml" ]]; then
rm -f coverage/lcov.info
rm -f coverage/lcov-final.info
cd movie
rm -f coverage/lcov.info
rm -f coverage/lcov-final.info
flutter test --coverage
lcov -r coverage/lcov.info lib/resources/l10n/\* lib/\*/fake_\*.dart \
-o coverage/lcov-final.info
genhtml -o coverage coverage/lcov-final.info
open coverage/index-sort-l.html
cd ..
cd search
rm -f coverage/lcov.info
rm -f coverage/lcov-final.info
flutter test --coverage
lcov -r coverage/lcov.info lib/resources/l10n/\* lib/\*/fake_\*.dart \
-o coverage/lcov-final.info
genhtml -o coverage coverage/lcov-final.info
open coverage/index-sort-l.html
cd ..
cd tv
rm -f coverage/lcov.info
rm -f coverage/lcov-final.info
flutter test --coverage
lcov -r coverage/lcov.info lib/resources/l10n/\* lib/\*/fake_\*.dart \
-o coverage/lcov-final.info
genhtml -o coverage coverage/lcov-final.info
open coverage/index-sort-l.html
cd ..
printf "\nMovie Module: ${green}ALL TEST PASSED${none} - ✅"
printf "\nSearch Module: ${green}ALL TEST PASSED${none} - ✅"
printf "\nTV Module: ${green}ALL TEST PASSED${none} - ✅"
else
printf "\n${red}Error: this is not a Flutter project${none}"
exit 1
fi
}
case $1 in
-h|--help)
show_help
;;
-t|--test)
run_tests
;;
-r|--report)
run_report
;;
*)
run_tests
;;
esac