Brain
Test Generation
OpenQA automatically generates comprehensive tests based on your application analysis.
Test Types Generated
Unit Tests
Isolated function and component tests
test_validateEmail()Functional Tests
User workflow and feature tests
test_loginFlow()E2E Tests
Complete user journey tests
test_purchaseCheckout()Security Tests
SQL injection, XSS, auth bypass
test_sqlInjection()Regression Tests
Bug fix verification tests
test_issue123_fix()Performance Tests
Load times and resource usage
test_pageLoadTime()How Tests Are Generated
1. Context Analysis
The Brain analyzes your application context:
- Application description and purpose
- Target URL and accessible pages
- Code structure (if repository connected)
- Custom directives you've provided
2. Test Planning
Based on analysis, the Brain plans which tests to generate:
json
1{2 "understanding": "E-commerce app with user auth, catalog, cart, checkout",3 "suggestedTests": [4 "Test cart persistence across sessions",5 "Test checkout validation with invalid cards",6 "Test product search functionality",7 "Test user registration flow"8 ],9 "risks": [10 "Cart race conditions",11 "Payment double-charge",12 "XSS in search input"13 ]14}3. Code Generation
Tests are generated as Playwright test files:
typescript
1// Generated: test_checkout_flow.spec.ts2import { test, expect } from '@playwright/test';3 4test('should complete checkout with valid card', async ({ page }) => {5 // Navigate to product6 await page.goto('https://your-app.com/products/1');7 8 // Add to cart9 await page.click('[data-testid="add-to-cart"]');10 11 // Go to checkout12 await page.click('[data-testid="checkout-button"]');13 14 // Fill payment form15 await page.fill('[name="cardNumber"]', '4242424242424242');16 await page.fill('[name="expiry"]', '12/25');17 await page.fill('[name="cvc"]', '123');18 19 // Submit20 await page.click('[type="submit"]');21 22 // Verify success23 await expect(page.locator('.success-message')).toBeVisible();24});Generate Specific Tests
You can request specific test generation via the API:
bash
1# Generate a security test2curl -X POST http://localhost:3000/api/brain/generate-test \3 -H "Content-Type: application/json" \4 -d '{5 "type": "security",6 "target": "Login form SQL injection",7 "context": "The login form at /login accepts email and password"8 }'9 10# Generate a functional test11curl -X POST http://localhost:3000/api/brain/generate-test \12 -H "Content-Type: application/json" \13 -d '{14 "type": "functional",15 "target": "User registration flow"16 }'Test Storage
Generated tests are stored in:
text
1openqa/2└── data/3 └── generated-tests/4 ├── test_checkout_flow.spec.ts5 ├── test_login_security.spec.ts6 ├── test_search_xss.spec.ts7 └── ...View Generated Tests
bash
1# List all generated tests2curl http://localhost:3000/api/tests3 4# Response:5# [6# {7# "id": "test_001",8# "name": "test_checkout_flow.spec.ts",9# "type": "e2e",10# "status": "passed",11# "createdAt": "2024-01-15T10:30:00Z"12# },13# ...14# ]