noiv generate
Generate comprehensive API tests using AI-powered natural language descriptions.
Syntax
noiv generate <description> [OPTIONS]
Description
The generate
command uses advanced AI to create complete API test suites from natural language descriptions. Perfect for:
- Rapid test creation - Generate complex tests in seconds
- Natural language testing - Describe what you want to test in plain English
- Comprehensive coverage - AI generates edge cases and validation scenarios
- Best practice tests - Generated tests follow industry standards
Arguments
<description>
(required)
Natural language description of what you want to test.
noiv generate "Test user registration with email validation"
noiv generate "Test product search with filters and pagination"
noiv generate "Test payment processing with different currencies"
Options
--output, -o
Output file for the generated test suite (default: generated_tests.yaml
).
noiv generate "Test user API" --output user_tests.yaml
noiv generate "Test e-commerce API" -o ecommerce_tests.yaml
--base-url, -u
Base URL for the API being tested.
noiv generate "Test user endpoints" --base-url https://api.example.com
noiv generate "Test local API" -u http://localhost:3000
--format, -f
Output format: yaml
(default), json
, or postman
.
noiv generate "Test API" --format json
noiv generate "Test API" -f postman
--complexity, -c
Test complexity level: basic
, standard
(default), or comprehensive
.
noiv generate "Test user API" --complexity basic
noiv generate "Test user API" -c comprehensive
--include-auth
Include authentication scenarios in generated tests.
noiv generate "Test protected endpoints" --include-auth
--include-edge-cases
Generate edge case and error scenario tests.
noiv generate "Test user registration" --include-edge-cases
--template, -t
Use a specific test template: rest
, graphql
, crud
, or e2e
.
noiv generate "Test user management" --template crud
noiv generate "Test GraphQL API" -t graphql
--interactive, -i
Enable interactive mode for guided test generation.
noiv generate "Test API" --interactive
Examples
Basic Test Generation
noiv generate "Test user registration and login"
Generated Output:
name: User Registration and Login Tests
base_url: https://api.example.com
tests:
- name: Register New User
request:
method: POST
path: /auth/register
headers:
Content-Type: application/json
body:
email: "test@example.com"
password: "SecurePass123"
username: "testuser"
expect:
status: 201
body:
id: "{{user_id}}"
email: "test@example.com"
headers:
Content-Type: application/json
- name: Login with Valid Credentials
request:
method: POST
path: /auth/login
headers:
Content-Type: application/json
body:
email: "test@example.com"
password: "SecurePass123"
expect:
status: 200
body:
token: "{{auth_token}}"
headers:
Content-Type: application/json
E-commerce API Tests
noiv generate "Test e-commerce product management with inventory" \
--base-url https://shop-api.example.com \
--complexity comprehensive \
--include-edge-cases
CRUD Operations
noiv generate "Test complete CRUD operations for blog posts" \
--template crud \
--output blog_tests.yaml
Authentication Testing
noiv generate "Test JWT authentication with refresh tokens" \
--include-auth \
--complexity comprehensive
Interactive Generation
noiv generate "Test payment system" --interactive
Interactive Flow:
🤖 AI Test Generator
Description: Test payment system
🎯 What type of payment system?
1. Credit card processing
2. Digital wallet (PayPal, Stripe)
3. Cryptocurrency
4. Bank transfers
5. All of the above
Choice: 2
💳 Which payment providers?
1. Stripe
2. PayPal
3. Square
4. Custom implementation
Choice: 1, 2
🔒 Include security testing?
1. Yes - Include fraud detection, validation
2. Basic - Standard payment flows only
Choice: 1
⚡ Test complexity?
1. Basic - Happy path scenarios
2. Standard - Common edge cases
3. Comprehensive - Full coverage including errors
Choice: 3
🚀 Generating comprehensive payment tests...
✅ Generated 23 test scenarios covering Stripe and PayPal integration
Test Templates
REST Template
noiv generate "Test user API" --template rest
Generates standard REST API tests:
- GET, POST, PUT, DELETE operations
- Query parameters and path variables
- Request/response validation
- Status code verification
CRUD Template
noiv generate "Test product management" --template crud
Generates complete CRUD operation tests:
- Create - POST with validation
- Read - GET single and list
- Update - PUT/PATCH operations
- Delete - DELETE with confirmation
GraphQL Template
noiv generate "Test GraphQL user queries" --template graphql
Generates GraphQL-specific tests:
- Query operations
- Mutation testing
- Subscription handling
- Schema validation
End-to-End Template
noiv generate "Test complete user journey" --template e2e
Generates workflow-based tests:
- Multi-step scenarios
- State management
- Session handling
- Business logic validation
Complexity Levels
Basic Level
noiv generate "Test user API" --complexity basic
Features:
- Happy path scenarios only
- Basic request/response validation
- Standard HTTP status codes
- Minimal test coverage
Standard Level (Default)
noiv generate "Test user API" --complexity standard
Features:
- Happy path + common error scenarios
- Input validation testing
- Authentication checks
- Moderate test coverage
Comprehensive Level
noiv generate "Test user API" --complexity comprehensive
Features:
- Full scenario coverage
- Edge cases and boundary testing
- Security and performance tests
- Maximum test coverage
AI Capabilities
Natural Language Understanding
The AI understands complex descriptions:
# Business logic
noiv generate "Test shopping cart with quantity limits and discount codes"
# Technical requirements
noiv generate "Test REST API with JWT auth, rate limiting, and pagination"
# User workflows
noiv generate "Test complete user onboarding from signup to first purchase"
Domain-Specific Knowledge
# E-commerce
noiv generate "Test inventory management with stock alerts"
# Finance
noiv generate "Test transaction processing with multi-currency support"
# Healthcare
noiv generate "Test patient record management with HIPAA compliance"
# Social media
noiv generate "Test content moderation and user reporting system"
Test Pattern Recognition
The AI automatically includes relevant patterns:
- Validation testing for form inputs
- Edge case handling for boundary values
- Error scenarios for failure modes
- Security testing for authentication
- Performance checks for load scenarios
Output Formats
YAML Format (Default)
noiv generate "Test API" --format yaml
name: Generated API Tests
base_url: https://api.example.com
variables:
user_id: ""
auth_token: ""
tests:
- name: Test Case
request:
method: GET
path: /endpoint
expect:
status: 200
JSON Format
noiv generate "Test API" --format json
{
"name": "Generated API Tests",
"base_url": "https://api.example.com",
"tests": [
{
"name": "Test Case",
"request": {
"method": "GET",
"path": "/endpoint"
},
"expect": {
"status": 200
}
}
]
}
Postman Collection
noiv generate "Test API" --format postman
Generates a Postman collection that can be imported directly into Postman.
Advanced Features
Variable Extraction
Generated tests automatically include variable extraction:
tests:
- name: Create User
request:
method: POST
path: /users
body:
name: "John Doe"
expect:
status: 201
body:
id: "{{user_id}}" # Extracted for use in subsequent tests
- name: Get Created User
request:
method: GET
path: /users/{{user_id}} # Uses extracted variable
Dependency Management
Tests are automatically ordered based on dependencies:
tests:
- name: Setup - Create User Account
# ... user creation
- name: Setup - Login User
depends_on: "Setup - Create User Account"
# ... user login
- name: Test - Update User Profile
depends_on: "Setup - Login User"
# ... profile update
Environment Configuration
environments:
development:
base_url: http://localhost:3000
variables:
api_key: "dev-key-123"
staging:
base_url: https://staging-api.example.com
variables:
api_key: "staging-key-456"
production:
base_url: https://api.example.com
variables:
api_key: "{{PROD_API_KEY}}"
Use Cases
API Development
# Generate tests during development
noiv generate "Test new user profile endpoints with image upload"
# Test API changes
noiv generate "Test updated payment flow with 3D Secure authentication"
Quality Assurance
# Comprehensive testing
noiv generate "Test complete e-commerce checkout process" --complexity comprehensive
# Edge case testing
noiv generate "Test user input validation" --include-edge-cases
Documentation
# Generate test examples for API documentation
noiv generate "Test all user management endpoints" --complexity basic
CI/CD Integration
# Generate tests for automated pipelines
noiv generate "Test critical user flows for regression testing"
Best Practices
1. Be Specific in Descriptions
Good:
noiv generate "Test user registration with email verification and password strength validation"
Better:
noiv generate "Test user registration API that requires email verification, enforces password complexity (8+ chars, uppercase, number, special char), and prevents duplicate emails"
2. Use Appropriate Complexity
# For rapid prototyping
noiv generate "Test basic CRUD operations" --complexity basic
# For production testing
noiv generate "Test payment processing" --complexity comprehensive
3. Include Context
# Include business context
noiv generate "Test e-commerce checkout process for subscription products with tax calculation"
# Include technical context
noiv generate "Test REST API with OAuth2 authentication and rate limiting"
4. Specify Output Organization
# Organize by feature
noiv generate "Test user management" --output tests/user_tests.yaml
# Organize by environment
noiv generate "Test production health checks" --output tests/prod_health.yaml
Integration with Other Commands
Generate and Test
# Generate tests
noiv generate "Test user API" --output user_tests.yaml
# Run generated tests
noiv test user_tests.yaml
Generate and Build Upon
# Generate initial tests
noiv generate "Test basic user CRUD" --complexity basic
# Use interactive builder to enhance
noiv build user_tests.yaml
Generate and Benchmark
# Generate performance tests
noiv generate "Test API performance under load" --template rest
# Run performance benchmarks
noiv benchmark generated_tests.yaml
Error Handling
Description Parsing Errors
noiv generate "vague description"
# Output: Description too vague. Please provide more specific details about the API functionality to test.
Missing Context
noiv generate "Test the API"
# Output: Please specify which API endpoints or functionality you want to test.
Invalid Parameters
noiv generate "Test API" --complexity invalid
# Output: Invalid complexity level. Use: basic, standard, or comprehensive
See Also
- noiv test - Run generated tests
- noiv build - Interactive test builder
- AI Generation Guide - Learn AI test generation
- Interactive Builder - Build tests step by step