FAQ¶
Common questions about VenomQA.
General¶
Q: What is VenomQA?
A: VenomQA is a state-based API testing framework that helps you test your entire application through state exploration. Unlike traditional API testing tools that test endpoints in isolation, VenomQA tests complete user workflows and verifies that your system remains consistent after every action.
Getting Started¶
Q: When should I use StateGraph vs Journey?
A: Use each approach for different scenarios:
| Scenario | Recommended Approach |
|---|---|
| Testing a specific user flow (login, checkout, etc.) | Journey |
| Exploring all possible state transitions | StateGraph |
| Smoke tests and quick sanity checks | Journey |
| Finding edge cases and unexpected paths | StateGraph |
| CI/CD integration | Both work well |
Journey is simpler and more intuitive - start here if you're new. It's like writing a script that a user would follow.
StateGraph is more powerful - it automatically explores all paths through your system and finds bugs that linear tests miss.
# Journey: Test one specific flow
journey = Journey(
name="checkout",
steps=[Step(name="login", action=login), Step(name="checkout", action=checkout)]
)
# StateGraph: Explore ALL state transitions
graph = StateGraph(name="shopping")
graph.add_node("empty", initial=True)
graph.add_node("has_items")
graph.add_edge("empty", "has_items", action=add_item)
graph.add_edge("has_items", "empty", action=remove_item)
result = graph.explore(client) # Tests all paths automatically
Q: Do I need PostgreSQL to use VenomQA?
A: No! PostgreSQL is optional and only needed for advanced features:
| Feature | Requires Database? |
|---|---|
| Basic Journey testing | No |
| HTTP assertions | No |
| Checkpoint/Branch (context only) | No |
| Checkpoint/Branch (database rollback) | Yes (PostgreSQL, MySQL, or SQLite) |
| StateGraph exploration | No (but recommended for full rollback) |
For most use cases, you can start without any database:
If you need database state rollback, add:
# venomqa.yaml - with PostgreSQL
base_url: "http://localhost:8000"
db_url: "postgresql://user:pass@localhost:5432/testdb"
db_backend: "postgresql"
Q: How do I test without a real API?
A: You have several options:
-
Use the test server we provide:
-
Use mocking (for unit testing the framework itself):
-
Use fixtures for predictable test data:
Q: What's the difference between context["key"] and context.get("key")?
A: They behave differently when the key doesn't exist:
# context["key"] - Raises KeyError if key doesn't exist
item_id = context["item_id"] # Crashes if item_id not set!
# context.get("key") - Returns None (or default) if key doesn't exist
item_id = context.get("item_id") # Returns None if not set
item_id = context.get("item_id", default=1) # Returns 1 if not set
# context.get_required("key") - Raises KeyError with a better error message
item_id = context.get_required("item_id") # KeyError: "Required context key not found: item_id"
Best practice: Use context.get() in most cases, and context.get_required() when the value MUST exist.
Common Errors¶
Q: I get "Connection refused" error. What's wrong?
A: Your API server isn't running or isn't accessible. Check:
-
Is the server running?
-
Is
base_urlcorrect invenomqa.yaml? -
If using Docker, is the network configured?
Q: I get "Journey not found" error. How do I fix it?
A: VenomQA can't find your journey file. Check:
-
Is the file in the right directory?
-
Does the file have a
journeyvariable? -
Are you using the correct name?
List available journeys:
Q: I get "KeyError: 'item_id'" in my action. What happened?
A: A previous step didn't set the value you're expecting. Common causes:
-
Previous step failed silently:
-
You're in a branch and context was reset: Branches restore context to the checkpoint state. Make sure the value was set BEFORE the checkpoint.
-
Typo in the key name:
Fix: Use defensive programming:
def get_item(client, context):
item_id = context.get("item_id")
if not item_id:
raise ValueError("item_id not set - did create_item succeed?")
return client.get(f"/items/{item_id}")
Q: How do I debug a failing step?
A: Use verbose mode and add logging:
-
Run with verbose output:
-
Add logging to your actions:
-
Check the response content:
Q: My step times out. How do I increase the timeout?
A: Set timeout at the step or journey level:
# Per-step timeout
Step(
name="long_operation",
action=long_operation,
timeout=120.0, # 2 minutes
)
# Default timeout for all steps in journey
journey = Journey(
name="my_journey",
timeout=60.0, # 1 minute default
steps=[...]
)
Or in venomqa.yaml:
Advanced Usage¶
Q: How do I run the same journey with different data?
A: Use the args parameter on steps:
def login(client, context, email, password):
return client.post("/login", json={"email": email, "password": password})
# Reuse the same action with different credentials
journey = Journey(
name="multi_user_test",
steps=[
Step(name="login_admin", action=login, args={"email": "admin@example.com", "password": "admin123"}),
Step(name="logout", action=logout),
Step(name="login_user", action=login, args={"email": "user@example.com", "password": "user123"}),
]
)
Q: How do I test authentication flows?
A: Store the token in context and use client.set_auth_token():
def login(client, context):
response = client.post("/auth/login", json={
"email": "test@example.com",
"password": "secret",
})
if response.status_code == 200:
token = response.json()["access_token"]
context["token"] = token
client.set_auth_token(token) # Sets Authorization: Bearer header
return response
def protected_action(client, context):
# Client automatically includes the auth header
return client.get("/api/protected")
Q: Can I use VenomQA with GraphQL APIs?
A: Yes! Use the GraphQL client:
from venomqa.clients.graphql import GraphQLClient
client = GraphQLClient("http://localhost:8000/graphql")
def get_users(client, context):
query = """
query {
users {
id
name
email
}
}
"""
return client.query(query)
def create_user(client, context):
mutation = """
mutation CreateUser($name: String!, $email: String!) {
createUser(name: $name, email: $email) {
id
name
}
}
"""
return client.query(mutation, variables={"name": "Test", "email": "test@example.com"})
Q: How do I integrate VenomQA with CI/CD?
A: VenomQA works with any CI system. Here's an example for GitHub Actions:
# .github/workflows/test.yml
name: API Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
services:
api:
image: your-api:latest
ports:
- 8000:8000
steps:
- uses: actions/checkout@v4
- name: Install VenomQA
run: pip install venomqa
- name: Run tests
run: venomqa run --all
- name: Generate report
if: always()
run: venomqa report --format junit --output results.xml
- name: Upload results
uses: actions/upload-artifact@v3
with:
name: test-results
path: results.xml
Q: How do I test error handling in my API?
A: Use expect_failure=True on steps that should fail:
journey = Journey(
name="error_handling",
steps=[
# Test 401 Unauthorized
Step(
name="access_without_auth",
action=lambda c, ctx: c.get("/api/protected"),
expect_failure=True,
),
# Test 404 Not Found
Step(
name="get_nonexistent",
action=lambda c, ctx: c.get("/api/items/99999"),
expect_failure=True,
),
# Test 422 Validation Error
Step(
name="invalid_input",
action=lambda c, ctx: c.post("/api/items", json={"price": "not_a_number"}),
expect_failure=True,
),
]
)
Troubleshooting¶
Q: VenomQA is slow. How do I speed it up?
A: Try these optimizations:
-
Use
--no-infraif services are already running: -
Reduce unnecessary waits:
-
Run tests in parallel (coming soon):
-
Use targeted test runs:
Q: Where can I get help?
A: You have several options:
- Check the documentation: https://venomqa.dev/docs
- Search existing issues: https://github.com/namanag97/venomqa/issues
- Open a new issue: https://github.com/namanag97/venomqa/issues/new
- Join the community: (Coming soon)
When reporting issues, include:
- VenomQA version (venomqa --version)
- Python version (python --version)
- Your venomqa.yaml config (remove secrets)
- The full error message and traceback