-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-test.sh
More file actions
executable file
·61 lines (48 loc) · 1.58 KB
/
run-test.sh
File metadata and controls
executable file
·61 lines (48 loc) · 1.58 KB
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
#!/bin/bash
set -euo pipefail
# Generic test runner script
# Usage: run-test.sh <test-type>
# Where test-type is one of: unit, integration, contract, schema, acceptance
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <test-type>"
echo "Where test-type is one of: unit, integration, contract, schema, acceptance"
exit 1
fi
TEST_TYPE="$1"
# Validate test type early
if [[ ! "$TEST_TYPE" =~ ^(unit|integration|contract|schema|acceptance)$ ]]; then
echo "Error: Unknown test type '$TEST_TYPE'" >&2
echo "Valid types are: unit, integration, contract, schema, acceptance" >&2
exit 1
fi
cd "$(git rev-parse --show-toplevel)"
# Determine test path based on test type
if [[ "$TEST_TYPE" = "unit" ]]; then
TEST_PATH="src"
else
TEST_PATH="tests/${TEST_TYPE}/"
fi
cd gateway-api
mkdir -p test-artefacts
echo "Running ${TEST_TYPE} tests..."
if [[ "$TEST_TYPE" = "unit" ]]; then
COV_PATH="."
poetry run pytest ${TEST_PATH} -v \
--cov=${COV_PATH} \
--cov-report=html:test-artefacts/coverage-html \
--cov-report=term \
--junit-xml="test-artefacts/${TEST_TYPE}-tests.xml" \
--html="test-artefacts/${TEST_TYPE}-tests.html" --self-contained-html
else
COV_PATH="src/gateway_api"
TEST_ENV="${ENV:-local}"
poetry run pytest ${TEST_PATH} -v \
--env="${TEST_ENV}" \
--cov=${COV_PATH} \
--cov-report=html:test-artefacts/coverage-html \
--cov-report=term \
--junit-xml="test-artefacts/${TEST_TYPE}-tests.xml" \
--html="test-artefacts/${TEST_TYPE}-tests.html" --self-contained-html
fi
# Save coverage data file for merging
mv .coverage "test-artefacts/coverage.${TEST_TYPE}"