A comprehensive API testing framework built with Python, specifically designed for testing Library Management Systems. This framework provides automated testing capabilities with proper structure, configuration management, reporting, and documentation.
- 🚀 Automated test case generation from HAR files
- 🌍 Multi-environment configuration support
- 📊 Comprehensive HTML test reports
- 📝 Detailed logging and debugging capabilities
- 🔧 Reusable test utilities and components
- 🔄 Session management for efficient API calls
- 📚 Extensive documentation
lib-management-automation/
├── config/ # Configuration files
│ ├── config.yaml # Environment configurations
│ └── logging_config.json # Logging settings
├── docs/ # Detailed documentation
│ └── framework.md # Framework documentation
├── reports/ # Test reports and logs
├── scripts/ # Utility scripts
│ └── generate_tests.py # Test generation script
├── tests/ # Test files
│ ├── test_cases/ # Generated test cases
│ ├── base_test.py # Base test class
│ └── conftest.py # Pytest configuration
├── utilities/ # Framework utilities
│ ├── api_client.py # API client
│ ├── config_manager.py # Configuration manager
│ ├── har_parser.py # HAR file parser
│ └── test_generator.py # Test generator
├── requirements.txt # Project dependencies
├── pytest.ini # Pytest configuration
└── README.md # Project documentation
- Python 3.8 or higher
- pip (Python package installer)
- virtualenv or venv
-
Clone the repository:
git clone <repository-url> cd lib-management-automation
-
Create and activate virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment:
- Copy your HAR file to project root
- Update configuration in
config/config.yaml - Set environment variables if needed
-
Generate tests:
python scripts/generate_tests.py
-
Start the API server:
# Make sure your API server is running at http://localhost:8980 # The tests expect the server to be available at this URL
-
Run tests:
# Run all tests pytest # Run with HTML report pytest --html=reports/report.html # Run specific test file pytest tests/test_cases/test_specific.py # Run by marker pytest -m smoke # Run tests with different base URL ENV=qa pytest # Uses the qa environment URL from config.yaml # Or override directly: API_TEST_BASE_URL="http://custom-api.example.com" pytest
Note: The tests require the API server to be running and accessible. If the server is not available, tests will be skipped with an appropriate message.
Configure different environments in config/config.yaml:
environments:
dev:
base_url: "http://localhost:8980"
timeout: 30
qa:
base_url: "https://qa-api.example.com"
timeout: 30ENV: Set environment (dev/qa/prod)API_TEST_*: Override any config value
Example:
export ENV=qa
export API_TEST_BASE_URL="https://custom-api.example.com"HTML reports are generated in the reports directory and include:
- Test execution summary
- Test case details and duration
- Failure information and screenshots
- Environment details
Logs are available in:
- Console output
reports/test_execution_[timestamp].log
from tests.base_test import BaseTest
class TestExample(BaseTest):
@pytest.mark.smoke
def test_example(self):
response = self.api_client.get('/endpoint')
self.validate_response(
response,
expected_status_code=200,
expected_values={'key': 'value'}
)@pytest.mark.smoke: Smoke tests@pytest.mark.regression: Regression tests@pytest.mark.api: API tests
- Framework Documentation: Detailed component documentation
- API Client: API request handling
- Configuration: Environment configuration
- Test Base: Common test utilities
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.