-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-api-tests.sh
More file actions
executable file
Β·137 lines (119 loc) Β· 4.51 KB
/
run-api-tests.sh
File metadata and controls
executable file
Β·137 lines (119 loc) Β· 4.51 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
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
#!/bin/bash
# π Suuupra EdTech Platform - API Test Runner
# Production-grade API testing script for all microservices
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Print banner
echo -e "${PURPLE}π Suuupra EdTech Platform - API Testing Suite${NC}"
echo -e "${CYAN}=================================================${NC}"
echo ""
# Check if Newman is installed
if ! command -v newman &> /dev/null; then
echo -e "${YELLOW}β οΈ Newman not found. Installing...${NC}"
npm install -g newman newman-reporter-html
fi
# Navigate to postman directory
cd postman/
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
echo -e "${BLUE}π¦ Installing dependencies...${NC}"
npm install
fi
# Create reports directory
mkdir -p reports
# Function to run tests
run_test() {
local test_name=$1
local collection=$2
local folder=$3
echo -e "${BLUE}π§ͺ Running ${test_name}...${NC}"
if [ -n "$folder" ]; then
newman run "$collection" \
-e environments/Local-Development.postman_environment.json \
--folder "$folder" \
--reporter-html \
--reporter-html-export "reports/$(echo ${test_name} | tr '[:upper:]' '[:lower:]')-report.html" \
--timeout 15000 \
--delay-request 100
else
newman run "$collection" \
-e environments/Local-Development.postman_environment.json \
--reporter-html \
--reporter-html-export "reports/$(echo ${test_name} | tr '[:upper:]' '[:lower:]')-report.html" \
--timeout 15000 \
--delay-request 100
fi
if [ $? -eq 0 ]; then
echo -e "${GREEN}β
${test_name} completed successfully${NC}"
else
echo -e "${RED}β ${test_name} failed${NC}"
fi
echo ""
}
# Parse command line arguments
case "${1:-all}" in
"health")
echo -e "${CYAN}π₯ Running Health Checks Only${NC}"
run_test "Health-Checks" "Simple-API-Tests.postman_collection.json"
;;
"auth")
echo -e "${CYAN}π Running Authentication Tests${NC}"
run_test "Authentication" "Production-API-Tests.postman_collection.json" "2. Authentication Flow"
;;
"payments")
echo -e "${CYAN}π³ Running Payment Tests${NC}"
run_test "Payments" "Production-API-Tests.postman_collection.json" "3. Banking & Payments"
;;
"upi")
echo -e "${CYAN}π Running UPI Tests${NC}"
run_test "UPI" "Production-API-Tests.postman_collection.json" "4. UPI Operations"
;;
"content")
echo -e "${CYAN}π Running Content Tests${NC}"
run_test "Content" "Production-API-Tests.postman_collection.json" "5. Content Management"
;;
"analytics")
echo -e "${CYAN}π Running Analytics Tests${NC}"
run_test "Analytics" "Production-API-Tests.postman_collection.json" "6. Analytics & Tracking"
;;
"notifications")
echo -e "${CYAN}π Running Notification Tests${NC}"
run_test "Notifications" "Production-API-Tests.postman_collection.json" "7. Notifications"
;;
"performance")
echo -e "${CYAN}β‘ Running Performance Tests${NC}"
run_test "Performance" "Production-API-Tests.postman_collection.json" "8. Performance & Load Testing"
;;
"production")
echo -e "${CYAN}π Running Full Production Test Suite${NC}"
run_test "Production-Full" "Production-API-Tests.postman_collection.json"
;;
"all"|*)
echo -e "${CYAN}π― Running Complete Test Suite${NC}"
echo ""
# Run health checks first
run_test "Health-Checks" "Simple-API-Tests.postman_collection.json"
# Run production tests
run_test "Production-Tests" "Production-API-Tests.postman_collection.json"
;;
esac
# Generate summary
echo -e "${PURPLE}π Test Execution Summary${NC}"
echo -e "${CYAN}=========================${NC}"
echo -e "${GREEN}β
All tests completed${NC}"
echo -e "${BLUE}π Reports available in: ./postman/reports/${NC}"
echo -e "${YELLOW}π Open HTML reports in browser to view detailed results${NC}"
echo ""
# List generated reports
echo -e "${CYAN}π Generated Reports:${NC}"
ls -la reports/*.html 2>/dev/null | awk '{print " π " $9}' || echo " No HTML reports found"
echo ""
echo -e "${GREEN}π API Testing Complete!${NC}"
echo -e "${BLUE}π Suuupra EdTech Platform is ready for production${NC}"