testzeus-knowledge-bases#
Access and use knowledge bases for AI context in TestZeus.
Category: integration · Version: 1.0.0 · Requires: testzeus-auth
Triggers: knowledge base, kb, context, documentation, api docs, use knowledge base, AI context, test context
Overview#
Knowledge bases in TestZeus provide AI context for test generation. They contain documentation, API specs, and other reference material that helps AI generate more accurate and relevant test cases.
Quick Reference#
# List knowledge bases
testzeus knowledge-bases list
# Get knowledge base details
testzeus knowledge-bases get kb_id
What is a Knowledge Base?#
A knowledge base typically contains:
API Documentation#
Endpoint specifications
Request/response formats
Authentication requirements
Error codes and handling
Business Logic#
Workflow descriptions
Rule documentation
Validation requirements
Test Guidelines#
Testing best practices
Known edge cases
Quality standards
List Knowledge Bases#
List All#
testzeus knowledge-bases list
Output:
NAME | TYPE | STATUS
------------------------|-----------|--------
API Documentation | api_spec | active
Product Docs | docs | active
Test Guidelines | guidelines| active
Filter by Type#
testzeus knowledge-bases list --filters type=api_spec
Get Details#
testzeus knowledge-bases get kb_id
Output:
Knowledge Base: API Documentation
ID: kb_abc123
Type: api_spec
Status: active
Contents:
- 15 endpoints documented
- 45 request/response schemas
- 12 authentication patterns
Used by: 3 test generators
Use with Test Generation#
During Test Creation#
When generating tests with AI, you can specify a knowledge base:
# Use API docs for test generation
testzeus testcase-generator create \
--test-id test_id \
--user-prompt "Generate tests for user CRUD operations using API documentation" \
--knowledge-base api_docs_kb_id
In SDK#
from testzeus_sdk import TestZeusClient
async def main():
async with TestZeusClient() as client:
# List available knowledge bases
kbs = await client.knowledge_bases.get_list()
for kb in kbs['items']:
print(f"{kb.name}: {kb.description}")
# Create test generator with KB context
generator = await client.tests_ai_generator.create({
"test_id": "test_id",
"user_prompt": "Generate tests using API docs",
"knowledge_base_id": "api_docs_kb_id"
})
Knowledge Base Types#
API Specification#
Contains API endpoint documentation:
REST endpoints
GraphQL schemas
WebSocket events
Example content:
{
"endpoints": [
{
"method": "POST",
"path": "/api/users",
"request": { ... },
"response": { ... }
}
]
}
Documentation#
General documentation:
Product manuals
User guides
Technical specs
Test Guidelines#
Testing best practices:
Required test scenarios
Edge case definitions
Quality checklists
Knowledge Base Best Practices#
1. Keep Documentation Updated#
❌ Outdated API docs → Incorrect test generation
✅ Current docs → Accurate test generation
2. Structure Content Clearly#
# User API
## Endpoints
### GET /api/users
- Returns list of users
- Requires: Bearer token
- Returns: User[]
## Data Models
### User
- id: string (UUID)
- name: string
- email: string
3. Include Examples#
{
"example_request": {
"name": "John Doe",
"email": "[email protected]"
},
"example_response": {
"id": "123",
"name": "John Doe",
"email": "[email protected]"
}
}
Common Use Cases#
API Testing#
Knowledge Base: API Documentation
└── Contains: OpenAPI spec, endpoint docs, schemas
└── Use: Generate API test cases
E-Commerce#
Knowledge Base: Product Catalog
└── Contains: Product types, categories, pricing rules
└── Use: Generate product-related test cases
Authentication#
Knowledge Base: Auth System
└── Contains: Login flows, token handling, permissions
└── Use: Generate auth test cases
SDK Usage#
from testzeus_sdk import TestZeusClient
async def main():
async with TestZeusClient() as client:
# List all knowledge bases
kbs = await client.knowledge_bases.get_list()
# Find specific KB
for kb in kbs['items']:
if 'api' in kb.name.lower():
api_kb = kb
break
# Use KB with test generation
generator = await client.tests_ai_generator.create({
"test_id": "my_test",
"user_prompt": "Test the checkout flow",
"knowledge_base_id": api_kb.id if api_kb else None
})
Error Handling#
Common Issues#
Issue |
Cause |
Solution |
|---|---|---|
KB not found |
Wrong ID |
List KBs first |
Empty KB |
No content |
Add documentation |
Outdated info |
Old docs |
Update content |
Verification#
Always verify KB content before using:
testzeus knowledge-bases get kb_id
# Review contents
Component Schema#
Use knowledge base info in responses:
{
"component": "KnowledgeBaseCard",
"props": {
"name": "API Documentation",
"type": "api_spec",
"status": "active",
"contentCount": 45,
"usedBy": 3
}
}