-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_start.py
More file actions
117 lines (90 loc) · 3.45 KB
/
quick_start.py
File metadata and controls
117 lines (90 loc) · 3.45 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
#!/usr/bin/env python
"""
Quick Start Script for Test Automation Framework Setup
This script helps set up and run tests with Allure reports.
"""
import subprocess
import sys
import os
def print_header(text):
"""Print formatted header."""
print("\n" + "=" * 60)
print(f" {text}")
print("=" * 60 + "\n")
def run_command(cmd, description):
"""Run a shell command."""
print(f"▶ {description}...")
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
if result.returncode == 0:
print(f"✓ {description} - SUCCESS\n")
return True
else:
print(f"✗ {description} - FAILED")
if result.stderr:
print(f"Error: {result.stderr}\n")
return False
except Exception as e:
print(f"✗ Error: {str(e)}\n")
return False
def main():
"""Main setup function."""
print_header("Test Automation Framework - Quick Start")
# Check Python version
print("Checking Python version...")
version = sys.version_info
print(f"Python {version.major}.{version.minor}.{version.micro}")
if version.major < 3 or (version.major == 3 and version.minor < 8):
print("❌ Python 3.8 or higher is required")
sys.exit(1)
print("✓ Python version OK\n")
# Install dependencies
print_header("Installing Dependencies")
if not run_command(
"pip install -r requirements-test.txt",
"Installing test dependencies"
):
print("⚠ Some dependencies may not have installed correctly")
# Check Chrome and ChromeDriver
print_header("Checking Browser Setup")
run_command("chrome --version", "Checking Chrome version")
run_command("chromedriver --version", "Checking ChromeDriver version")
print_header("Setup Complete!")
print("""
🎯 Next Steps:
1. START THE FLASK APPLICATION:
python app.py
(Keep it running in a separate terminal)
2. RUN ALL TESTS:
pytest TestAutomation/Tests/ExpenseTest.py -v --alluredir=allure-results
3. RUN SPECIFIC TEST SUITE:
pytest TestAutomation/Tests/ExpenseTest.py::TestAddExpense -v --alluredir=allure-results
pytest TestAutomation/Tests/ExpenseTest.py::TestDeleteExpense -v --alluredir=allure-results
pytest TestAutomation/Tests/ExpenseTest.py::TestClearExpenses -v --alluredir=allure-results
4. RUN SMOKE TESTS ONLY:
pytest TestAutomation/Tests/ExpenseTest.py -m smoke -v --alluredir=allure-results
5. GENERATE ALLURE REPORT:
allure serve allure-results
📊 Test Results:
- Logs: Logs/automation_YYYYMMDD_HHMMSS.log
- Screenshots: Screenshots/ (on failures)
- Allure Reports: allure-results/
📖 Documentation:
Read README_AUTOMATION.md for detailed information and examples.
✨ Quick Command Reference:
# Run all tests with Allure
pytest TestAutomation/Tests/ExpenseTest.py -v --alluredir=allure-results
# View test report
allure serve allure-results
# Run tests in parallel (4 workers)
pytest TestAutomation/Tests/ExpenseTest.py -v -n 4 --alluredir=allure-results
# Run with custom marker
pytest TestAutomation/Tests/ExpenseTest.py -m add_expense -v --alluredir=allure-results
💡 Tips:
- Keep the Flask application running on http://127.0.0.1:5000
- Check logs in Logs/ directory for debugging
- Screenshots are saved on test failures
- Use allure serve to view interactive reports
""")
if __name__ == "__main__":
main()