> ## Documentation Index
> Fetch the complete documentation index at: https://onetest.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Tests with AI

> Create complete test cases in seconds using natural language

The AI Assistant can generate complete, detailed test cases in seconds. Just describe what you want to test, and the AI creates a fully-formed test case with steps, expected results, and tags.

## Quick Start

**1. Open the AI Chat**

Press `Cmd + K` (Mac) or `Ctrl + K` (Windows/Linux)

**2. Describe What to Test**

Type your request in plain English:

```
Create a test for user login with valid credentials
```

**3. Review the Generated Test**

The AI will create a complete test case with:

* Clear title
* Test steps with expected results
* Preconditions
* Tags
* Priority

**4. Save or Refine**

* Click **"Save"** to add it to your test suite
* Or ask the AI to modify it: "Add a step for two-factor authentication"

## Generation Patterns

> [tab] Single Test
>
> **Create one specific test:**
>
> ```
> Create a test for password reset
> ```
>
> ```
> Generate a test case for adding items to cart
> ```
>
> ```
> Write a test for user profile update
> ```
>
> The AI will generate a single, focused test case.

> [tab] Multiple Tests
>
> **Create a suite of related tests:**
>
> ```
> Generate smoke tests for the checkout flow
> ```
>
> ```
> Create regression tests for user authentication
> ```
>
> ```
> Generate API tests for the products endpoint
> ```
>
> The AI will create multiple test cases covering different scenarios.

> [tab] From Requirements
>
> **Generate from user stories or requirements:**
>
> ```
> Create tests for this user story:
>
> As a user, I want to filter products by price range
> so that I can find items within my budget.
> ```
>
> The AI will analyze the requirement and generate appropriate tests.

> [tab] From Documentation
>
> **Generate from API docs or specifications:**
>
> ```
> Generate API tests from these docs:
>
> POST /api/users
> Creates a new user account
>
> Request Body:
> - email (required): string
> - password (required): string (min 8 chars)
> - name (optional): string
>
> Response: 201 Created
> ```
>
> The AI will create tests covering all scenarios and edge cases.

## What Gets Generated

When you ask the AI to create a test, it automatically generates:

> [card] Test Metadata
>
> * Unique identifier (TC-XXXX)
> * Clear, descriptive title
> * Appropriate priority (P0-P4)
> * Relevant tags
> * Test type (manual/automated)

> [card] Test Content
>
> * Preconditions
> * Detailed test steps
> * Expected results for each step
> * Overall pass/fail criteria
> * Test data (when applicable)

> [card] Best Practices
>
> * Follows naming conventions
> * Includes edge cases
> * Uses clear language
> * Atomic test design

> [card] Context Awareness
>
> * Matches your product type
> * Uses existing tags
> * Follows team patterns
> * Considers related tests

## Example Prompts

> [accordion] E-commerce Tests
>
> ```
> Generate smoke tests for e-commerce checkout
> ```
>
> **AI generates:**
>
> * Add item to cart
> * Update cart quantities
> * Apply discount code
> * Select shipping method
> * Enter payment information
> * Complete purchase
> * Receive confirmation email

> [accordion] API Tests
>
> ```
> Create API tests for user CRUD operations
> ```
>
> **AI generates:**
>
> * Create user (valid data)
> * Create user (invalid email)
> * Create user (duplicate email)
> * Get user by ID
> * Update user information
> * Delete user
> * Verify deletion

> [accordion] Mobile App Tests
>
> ```
> Generate tests for mobile app onboarding
> ```
>
> **AI generates:**
>
> * First launch experience
> * Permission requests
> * Account creation
> * Profile setup
> * Feature introduction screens
> * Skip onboarding flow
> * Complete onboarding

> [accordion] Security Tests
>
> ```
> Create security tests for login
> ```
>
> **AI generates:**
>
> * SQL injection attempts
> * XSS attack prevention
> * Brute force protection
> * Session fixation prevention
> * CSRF token validation
> * Password complexity enforcement
> * Account lockout after failures

## Refining Generated Tests

You can iterate with the AI to refine tests:

**1. Ask for Modifications**

```
Add a step to verify email notification is sent
```

```
Make this test cover mobile view as well
```

```
Split this into separate positive and negative tests
```

**2. Request Different Formats**

```
Make this more detailed with specific test data
```

```
Simplify this test to just the happy path
```

```
Convert this to an API test
```

**3. Add Context**

```
This is for a healthcare app, add HIPAA compliance checks
```

```
We use Stripe for payments, update the payment steps
```

```
Include accessibility testing requirements
```

## Advanced Techniques

> [tab] Batch Generation
>
> Generate many tests at once:
>
> ```
> Create a complete test suite for the shopping cart feature including:
> - Adding items
> - Updating quantities
> - Removing items
> - Cart persistence
> - Checkout initiation
> ```
>
> The AI will create 10-15 related tests covering all aspects.

> [tab] From Screenshots
>
> Upload UI screenshots:
>
> ```
> Generate tests for this login screen [attach screenshot]
> ```
>
> The AI analyzes the UI and creates appropriate tests.

> [tab] Test Variations
>
> Generate test variations:
>
> ```
> Create the same login test but for:
> - Desktop web
> - Mobile web
> - iOS app
> - Android app
> ```
>
> The AI creates platform-specific test cases.

> [tab] Edge Cases
>
> Focus on edge cases:
>
> ```
> What edge cases should I test for file upload?
> ```
>
> The AI suggests and can generate tests for:
>
> * Empty file
> * File too large
> * Invalid file type
> * Special characters in filename
> * Network interruption
> * Concurrent uploads

## Quality Assurance

> [!NOTE]
>
> **Review AI Output:** Always review generated tests to ensure they match your specific requirements and context.

> [!TIP]
>
> **Provide Feedback:** Tell the AI what to adjust: "Make step 3 more specific" or "Add assertions for response time"

> [!WARNING]
>
> **Test Data:** Be cautious with sensitive data. The AI generates sample data, but you should use appropriate test data for your environment.

## Best Practices

> [card] Be Specific
>
> Instead of "create a login test," try "create a test for login with OAuth via Google"

> [card] Provide Context
>
> Mention the feature, platform, or user story: "Create a test for the new multi-factor authentication feature on mobile"

> [card] Iterate
>
> Refine the test through conversation: "Add error handling scenarios" or "Include performance assertions"

> [card] Save Templates
>
> Once you get a good test format, save it as a template for consistency

## What's Next?

> [card] [Search Your Tests](https://onetest.ai/ai/search-tests.md)
>
> Find tests using natural language

> [card] [Ask Questions](https://onetest.ai/ai/ask-questions.md)
>
> Get insights about your test suite

> [card] [Organize Tests](https://onetest.ai/workflows/organizing-tests.md)
>
> Use folders and tags effectively

> [card] [Best Practices](https://onetest.ai/ai/best-practices.md)
>
> Advanced AI tips and techniques


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.