Skip to content

Commit 0b1c778

Browse files
Merge pull request #358 from SatelCreative/feature/run_specific_tests
✨ Add help menu and ability to run specific tests for validatecodeonce
2 parents 32c201e + 08e7f87 commit 0b1c778

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ code change.
136136
This can be used for CI/CD purposes since it generates report files in the `/python/reports`
137137
folder.
138138

139+
Options:\
140+
`-h` Print help menu.
141+
```
142+
validatecodeonce -h
143+
```
144+
`-k` Invoke Pytest option `-k` to run specific tests based on a substring match to the test name.
145+
```
146+
validatecodeonce -k test_get_products
147+
```
148+
139149
### `runtests` (DEPRECATED)
140150

141151
**DEPRECATED**: Use `validatecodeonce` instead

entrypoint.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,29 @@ validatecode() {
5252
}
5353

5454
validatecodeonce() {
55+
help() {
56+
echo
57+
echo "Usage: validatecodeonce [-h|k]"
58+
echo
59+
echo "Trigger a single run of code validation."
60+
echo
61+
echo "Options:"
62+
echo "h Print this help menu."
63+
echo "k Invoke Pytest option -k to run specific tests based on a substring match to the test name."
64+
echo
65+
}
66+
67+
while getopts ":h" option; do
68+
case $option in
69+
h)
70+
help
71+
exit;;
72+
esac
73+
done
74+
5575
echo -e "\nTriggering single run of code validation."
56-
5776
loadconfig
58-
../test_suite.sh reports
77+
../test_suite.sh $@ reports
5978
}
6079

6180

test_suite.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
REPORTS_FOLDER="/python/reports/"
44
SECTION_PREFIX="\n#########"
55

6+
while getopts ":k:" option; do
7+
case $option in
8+
k)
9+
SPECIFIC_TESTS="-k ${OPTARG}"
10+
esac
11+
done
612

713
checkuser() {
814
WHOAMI=`whoami`
@@ -35,7 +41,7 @@ then
3541
fi
3642

3743
echo -ne "$SECTION_PREFIX RUN TESTS:\n\n"
38-
python -m pytest -vv --durations=3 --cov ./ --cov-report term-missing $PYTEST_REPORTS; STATUS1=$?
44+
python -m pytest -vv --durations=3 --cov ./ --cov-report term-missing $PYTEST_REPORTS $SPECIFIC_TESTS; STATUS1=$?
3945

4046
echo -ne "$SECTION_PREFIX CHECK DOCKER USER IS PYTHON: "
4147
USEROUT=`checkuser`

0 commit comments

Comments
 (0)