OpenQAOpenQA
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
{
  "understanding": "E-commerce app with user auth, catalog, cart, checkout",
  "suggestedTests": [
    "Test cart persistence across sessions",
    "Test checkout validation with invalid cards",
    "Test product search functionality",
    "Test user registration flow"
  ],
  "risks": [
    "Cart race conditions",
    "Payment double-charge",
    "XSS in search input"
  ]
}

3. Code Generation

Tests are generated as Playwright test files:

typescript
// Generated: test_checkout_flow.spec.ts
import { test, expect } from '@playwright/test';

test('should complete checkout with valid card', async ({ page }) => {
  // Navigate to product
  await page.goto('https://your-app.com/products/1');
  
  // Add to cart
  await page.click('[data-testid="add-to-cart"]');
  
  // Go to checkout
  await page.click('[data-testid="checkout-button"]');
  
  // Fill payment form
  await page.fill('[name="cardNumber"]', '4242424242424242');
  await page.fill('[name="expiry"]', '12/25');
  await page.fill('[name="cvc"]', '123');
  
  // Submit
  await page.click('[type="submit"]');
  
  // Verify success
  await expect(page.locator('.success-message')).toBeVisible();
});

Generate Specific Tests

You can request specific test generation via the API:

bash
# Generate a security test
curl -X POST http://localhost:3000/api/brain/generate-test \
  -H "Content-Type: application/json" \
  -d '{
    "type": "security",
    "target": "Login form SQL injection",
    "context": "The login form at /login accepts email and password"
  }'

# Generate a functional test
curl -X POST http://localhost:3000/api/brain/generate-test \
  -H "Content-Type: application/json" \
  -d '{
    "type": "functional",
    "target": "User registration flow"
  }'

Test Storage

Generated tests are stored in:

text
openqa/
└── data/
    └── generated-tests/
        ├── test_checkout_flow.spec.ts
        ├── test_login_security.spec.ts
        ├── test_search_xss.spec.ts
        └── ...

View Generated Tests

bash
# List all generated tests
curl http://localhost:3000/api/tests

# Response:
# [
#   {
#     "id": "test_001",
#     "name": "test_checkout_flow.spec.ts",
#     "type": "e2e",
#     "status": "passed",
#     "createdAt": "2024-01-15T10:30:00Z"
#   },
#   ...
# ]

Next Steps