From 966d2fcde3e0ef59615fac5b962dd6cb4346e0f8 Mon Sep 17 00:00:00 2001 From: ConnorQi01 Date: Tue, 28 Apr 2026 16:47:48 +0800 Subject: [PATCH] feat: add one-click test runner scripts for API and UI tests --- run_api.bat | 19 +++++++++++++++++++ run_api.sh | 13 +++++++++++++ run_ui.bat | 21 +++++++++++++++++++++ run_ui.sh | 24 ++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 run_api.bat create mode 100644 run_api.sh create mode 100644 run_ui.bat create mode 100644 run_ui.sh diff --git a/run_api.bat b/run_api.bat new file mode 100644 index 0000000..43f488e --- /dev/null +++ b/run_api.bat @@ -0,0 +1,19 @@ +@echo off +REM One-click API test runner +set REPORT_DIR=.\Reports\api-results +set OUTPUT_DIR=.\Reports\api-report + +echo === Running API Tests === +pytest API_Automation/cases -v --alluredir="%REPORT_DIR%" +if errorlevel 1 goto :error + +echo === Generating Allure Report === +allure generate "%REPORT_DIR%" -o "%OUTPUT_DIR%" --clean +allure open "%OUTPUT_DIR%" +goto :end + +:error +echo Tests failed. +exit /b 1 + +:end diff --git a/run_api.sh b/run_api.sh new file mode 100644 index 0000000..5e06332 --- /dev/null +++ b/run_api.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# One-click API test runner +set -e + +REPORT_DIR="./Reports/api-results" +OUTPUT_DIR="./Reports/api-report" + +echo "=== Running API Tests ===" +pytest API_Automation/cases -v --alluredir="$REPORT_DIR" + +echo "=== Generating Allure Report ===" +allure generate "$REPORT_DIR" -o "$OUTPUT_DIR" --clean +allure open "$OUTPUT_DIR" diff --git a/run_ui.bat b/run_ui.bat new file mode 100644 index 0000000..9482452 --- /dev/null +++ b/run_ui.bat @@ -0,0 +1,21 @@ +@echo off +REM One-click UI test runner (requires Appium + device/simulator) +set REPORT_DIR=.\Reports\ui-results +set OUTPUT_DIR=.\Reports\ui-report + +echo === Starting Appium Server === +start /b appium +timeout /t 3 /nobreak >nul + +echo === Running UI Tests === +pytest UI_Automation/Tests -v -n 0 --alluredir="%REPORT_DIR%" +set EXIT_CODE=%errorlevel% + +echo === Stopping Appium Server === +taskkill /f /im node.exe >nul 2>&1 + +echo === Generating Allure Report === +allure generate "%REPORT_DIR%" -o "%OUTPUT_DIR%" --clean +allure open "%OUTPUT_DIR%" + +exit /b %EXIT_CODE% diff --git a/run_ui.sh b/run_ui.sh new file mode 100644 index 0000000..8303ddc --- /dev/null +++ b/run_ui.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# One-click UI test runner (requires Appium + device/simulator) +set -e + +REPORT_DIR="./Reports/ui-results" +OUTPUT_DIR="./Reports/ui-report" + +echo "=== Starting Appium Server ===" +appium & +APPIUM_PID=$! +sleep 3 + +echo "=== Running UI Tests ===" +pytest UI_Automation/Tests -v -n 0 --alluredir="$REPORT_DIR" +EXIT_CODE=$? + +echo "=== Stopping Appium Server ===" +kill $APPIUM_PID + +echo "=== Generating Allure Report ===" +allure generate "$REPORT_DIR" -o "$OUTPUT_DIR" --clean +allure open "$OUTPUT_DIR" + +exit $EXIT_CODE