AI Test Generation
NOIV's AI-powered test generation is one of its most powerful features. Transform natural language descriptions into comprehensive API test suites using advanced AI.
How It Works
NOIV uses Google Gemini AI to understand your natural language descriptions and generate appropriate API tests. Simply describe what you want to test in plain English, and NOIV creates the test scenarios.
Basic Usage
noiv generate natural "test user authentication API"
This simple command generates a complete test suite with multiple scenarios.
Writing Effective Descriptions
The key to getting great test generation results is writing clear, descriptive prompts.
✅ Good Examples
# Comprehensive e-commerce testing
noiv generate natural "test e-commerce API with user registration, product search, shopping cart operations, and checkout process"
# Authentication focus
noiv generate natural "test user management system with login, registration, password reset, and profile updates"
# Error handling
noiv generate natural "test blog API with CRUD operations, authentication, and proper error handling for invalid requests"
❌ Poor Examples
# Too vague
noiv generate natural "test API"
# Too technical/specific
noiv generate natural "POST /api/v1/users with 201 status"
Generated Test Structure
When you run AI generation, NOIV creates a YAML file with this structure:
name: 'Tests: Your description'
tests:
- name: Test Case 1
url: https://api.example.com/endpoint
method: GET
expected_status: 200
headers:
Content-Type: application/json
validations:
- type: json_path
path: $.data.id
expected: "exists"
- name: Test Case 2
# ... more tests
Advanced Prompting
Specify API Details
Include specific API information for better results:
noiv generate natural "test RESTful user management API at api.myapp.com with JWT authentication, including user CRUD operations and role-based permissions"
Include Error Scenarios
Ask for comprehensive testing including edge cases:
noiv generate natural "test payment processing API with successful payments, declined cards, invalid amounts, and network timeouts"
Multiple Environments
Generate tests for different environments:
noiv generate natural "test social media API for posting, commenting, and user interactions with proper authentication and rate limiting"
Customizing Generated Tests
After generation, you can modify the YAML file to:
Add Custom Headers
headers:
Authorization: "Bearer ${API_TOKEN}"
X-API-Version: "v2"
Custom-Header: "value"
Include Request Bodies
body: |
{
"username": "testuser",
"email": "test@example.com",
"password": "securepass123"
}
Enhanced Validations
validations:
- type: status_code
expected: 201
- type: header
name: Location
expected: "contains:/users/"
- type: json_path
path: $.user.email
expected: "test@example.com"
- type: contains
value: "created successfully"
Real-World Examples
E-commerce Platform
noiv generate natural "test complete e-commerce platform with user authentication, product catalog with search and filtering, shopping cart management, order processing with payment integration, and admin panel for inventory management"
Generated structure:
- User registration/login tests
- Product search and filtering
- Cart operations (add, remove, update)
- Checkout and payment flow
- Admin inventory management
Microservices API
noiv generate natural "test microservices architecture with user service, order service, payment service, and notification service, including inter-service communication and circuit breaker patterns"
Content Management System
noiv generate natural "test CMS API with content creation, editing, publishing workflow, media uploads, user permissions, and SEO metadata management"
Best Practices
1. Be Descriptive but Concise
# Good balance
noiv generate natural "test inventory management API with product CRUD, stock tracking, low inventory alerts, and supplier management"
2. Include Business Logic
# Includes business rules
noiv generate natural "test booking system with availability checking, reservation creation, cancellation policies, and payment processing with refund handling"
3. Mention Authentication
# Security-aware
noiv generate natural "test secure API with OAuth2 authentication, role-based access control, and data validation for financial transactions"
4. Specify Data Types
# Data-specific
noiv generate natural "test analytics API with time-series data collection, aggregation queries, dashboard metrics, and CSV export functionality"
Environment Variables
Use environment variables in your tests for different environments:
tests:
- name: Login Test
url: "${BASE_URL}/auth/login"
headers:
Authorization: "Bearer ${API_TOKEN}"
Set them before running:
export BASE_URL="https://staging-api.example.com"
export API_TOKEN="your-token-here"
noiv test run generated_tests.yaml
Troubleshooting
AI Generation Issues
If generation doesn't work as expected:
- Check internet connection - AI features require connectivity
- Simplify your prompt - Try a shorter, clearer description
- Be more specific - Add details about the API you're testing
- Review output - Generated tests may need manual adjustments
Common Fixes
# If generation fails, try simpler prompts
noiv generate natural "test user login and registration"
# Then build up complexity
noiv generate natural "test user authentication system with email verification and password reset"
Next Steps
- Run your tests - Execute generated test suites
- Performance testing - Add benchmarking to your tests
- HTML reports - Generate professional test reports
- Quick Start - Learn testing strategies
TIP
Generated tests are starting points. Feel free to modify the YAML files to match your specific API requirements and add custom validations.