A comprehensive testing framework for REST APIs with functional and performance testing capabilities
Project description
RapidTest 🚀
A super lightweight and blazingly fast library to simplify REST API testing. Designed to be intuitive, fast to implement.
✨ Features
- Simplicity: Perform HTTP requests (
GET,POST,PUT,PATCH,DELETE) in a single line with comprehensive response validation. - Automatic Validation: Automatically compare status codes and response bodies with detailed error reporting.
- Data Generator: Integrated random data generator (using Faker) for dynamic testing with flexible user creation.
- Performance Testing: Built-in load testing with threading - no external tools needed!
🛠️ Installation
Install the required dependencies:
pip install rapidtest
🚀 Quick Start
1. Initialize RapidTest
from rapidtest import Test
# Configure your API's base URL
tester = Test(url="http://localhost:8000")
2. Run Tests
GET
tester.get(endpoint="/users", expected_status=200)
POST with Body Validation
user_data = {"username": "Uziel", "password": "Mypass123"}
tester.post(endpoint="/user", json=user_data, expected_status=201, expected_json=user_data)
Advanced Example with Dynamic Data
from rapidtest import Test, data
# Initialize tester
tester = Test(url="http://127.0.0.1:8000")
# Generate dynamic test data
user = data.generate_user(id=True, name=True, email=True, age=True, password=True, username=True)
# Test user creation
tester.post(endpoint="/user", json=user, expected_status=201)
3. Generate Random Data
Use the data class to create test data on the fly:
from rapidtest import data
# Generate specific data types
auth_user = data.generate_auth_user()
email = data.generate_email()
name = data.generate_name()
phone = data.generate_phone()
print(auth_user) # {'username': '...', 'password': '...'}
Additional Parameters
All HTTP methods support additional parameters:
# Query parameters
tester.get(endpoint="/users", params={"page": 1, "limit": 10})
# Custom headers
tester.post(endpoint="/auth", json=user_data, headers={"Content-Type": "application/json"})
⚡ RapidTest vs FastAPI TestClient
See the difference yourself! RapidTest dramatically simplifies your testing code:
📋 FastAPI's TestClient Approach
# Traditional FastAPI TestClient - More verbose
from fastapi.testclient import TestClient
from api import app
client = TestClient(app)
def test_read_item():
response = client.get("/items/foo")
assert response.status_code == 200
assert response.json() == {"id": "foo", "title": "Foo"}
# Result: 4 lines for the test
🚀 RapidTest Approach
# RapidTest - Clean and concise
from rapidtest import Test
fastTest = Test(url="http://localhost:8000")
fastTest.get(endpoint="/items/foo", expected_status=200, expected_json={"id": "foo", "title": "Foo"})
# Result: 2 lines for the test
🎯 Key Advantages
| Feature | FastAPI TestClient | RapidTest |
|---|---|---|
| Lines of code | 4+ lines | 2 lines |
| Assertions | Manual assert statements |
Built-in validation |
| Setup complexity | Import app, create client | Simple URL configuration |
| Error reporting | Basic assertion errors | Detailed, colored output |
| Data generation | Manual or external tools | Built-in data class |
| Performance testing | Requires additional tools | Built-in Performance class |
Result: 50% less code, 100% more clarity! ✨
🚀 Performance Testing
Use the Performance class to run simple load tests on your APIs:
Beta*
from rapidtest import Performance
# Initialize performance test
perf = Performance(
base_url="http://localhost:8000",
users=10, # Number of concurrent users
duration=30, # Test duration in seconds
timeout=10 # Request timeout
)
# Add endpoint to test
perf.add_get_task(endpoint="/api/users")
# Run the test and shown results in terminal)
perf.run()
Performance Test Output
See real results in action:
📊 Reports
See how your tests look with real colorized output:
✅ Successful Test
❌ Failed Test
📁 Project Structure
rapidtest/RapidTest.py: Core library logic with comprehensive API testing methods and detailed response handlingRapidData.py: Random data generator with flexible user creation and comprehensive fake dataPerformance.py: Simple performance testing (no external deps)Utils.py: Formatting and reporting utilities__init__.py: Module configuration
🔧 Dependencies
requests>=2.25.1: For making HTTP requestsfaker>=13.0.0: For generating fake data
📋 Requirements
- Python >=3.7
📖 Project Information
- Version: 0.3.3
- Author: Hector Rosales
- License: MIT
- Homepage: https://github.com/hector-dev/rapidtest
⚡ Built for speed and simplicity - because testing should be fast and fun! 🛠️✨
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rapidtest-0.3.3.tar.gz.
File metadata
- Download URL: rapidtest-0.3.3.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa68185a341304496da27fcf27d8728b5f813ba221aec7e4dc233f6e60985da
|
|
| MD5 |
49baa34f01c896bc89d7e5111d71884d
|
|
| BLAKE2b-256 |
77a88e8ff17e121502423d249dff29b1c00c8ed9b3b8db891ed92b412cb7269e
|
File details
Details for the file rapidtest-0.3.3-py3-none-any.whl.
File metadata
- Download URL: rapidtest-0.3.3-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98f15695f119f18dec5761c74bc1c399d24d30586d464b5191b3fa74d6b6351d
|
|
| MD5 |
28adfd079c613099cb4bc3e72d718de4
|
|
| BLAKE2b-256 |
bc6b3521695952a03109ad15ecae300a5e792bc4036013e03b7376377e34a90b
|