-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.bat
More file actions
110 lines (96 loc) · 2.81 KB
/
run_tests.bat
File metadata and controls
110 lines (96 loc) · 2.81 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
@echo off
REM TopicsFlow Backend API Test Runner
REM This script clears test data and runs Postman collection tests
echo ========================================
echo TopicsFlow Backend API Test Suite
echo ========================================
echo.
REM Check if Node.js is installed
where node >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Node.js is not installed or not in PATH
echo Please install Node.js from https://nodejs.org/
pause
exit /b 1
)
REM Check if Python is installed
where python >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo [WARNING] Python not found. Skipping database cleanup.
echo You may need to manually clear test data from MongoDB.
goto :skip_cleanup
)
REM Step 1: Clear test data from database
echo [1/4] Clearing test data from database...
echo.
python clear_test_data.py
if %ERRORLEVEL% NEQ 0 (
echo [WARNING] Failed to clear test data. Continuing anyway...
echo.
)
echo.
:skip_cleanup
REM Step 2: Check if Newman is installed
echo [2/4] Checking Newman installation...
where newman >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo Newman not found. Installing...
call npm install -g newman
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Failed to install Newman
pause
exit /b 1
)
)
echo ✓ Newman is installed
echo.
REM Step 3: Check if HTML reporter is installed
echo [3/4] Checking HTML reporter...
call npm list -g newman-reporter-html >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo HTML reporter not found. Installing...
call npm install -g newman-reporter-html
if %ERRORLEVEL% NEQ 0 (
echo [WARNING] Failed to install HTML reporter. Tests will run without HTML report.
) else (
echo ✓ HTML reporter installed
)
) else (
echo ✓ HTML reporter is installed
)
echo.
REM Step 4: Create reports directory if it doesn't exist
if not exist "Tests\reports" (
mkdir Tests\reports
)
REM Step 5: Run Postman collection tests
echo [4/4] Running Postman collection tests...
echo.
echo ========================================
echo Running Tests...
echo ========================================
echo.
newman run Tests\postman\TopicsFlow_Backend_API.postman_collection.json ^
-e Tests\postman\environments\Local.postman_environment.json ^
-r html,cli ^
--reporter-html-export Tests\reports\report.html ^
--delay-request 500
set TEST_EXIT_CODE=%ERRORLEVEL%
echo.
echo ========================================
if %TEST_EXIT_CODE% EQU 0 (
echo ✓ All tests passed!
) else (
echo ✗ Some tests failed. Exit code: %TEST_EXIT_CODE%
)
echo ========================================
echo.
echo Test report saved to: Tests\reports\report.html
echo.
REM Open report in browser (optional)
if exist "Tests\reports\report.html" (
echo Opening test report in browser...
start Tests\reports\report.html
)
pause
exit /b %TEST_EXIT_CODE%