> For the complete documentation index, see [llms.txt](https://docs.flosum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flosum.com/devops/code/code-tools/using-ai-test-class.md).

# Using AI Test Class

{% hint style="warning" %}

#### Written for the Old UI

This article was written for the old UI. The instructions are still usable, but the screenshots are outdated. In some cases, items referenced in the instructions have moved or changed. If you cannot find an item, see the [Where Did It Go](/devops/new-ui-ux-transition/where-did-it-go.md) article.
{% endhint %}

## ![](https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FG5ZbxX918xOHwbAwAJ4n%2FSummary2-Small-Icon.svg?alt=media\&token=da26a67f-ff7f-47b3-8669-06be960dc2d7) Overview

This article explains how to use the AI Test Class Creator to automatically generate a Salesforce test class for the selected component. Once generated, you can review and commit the test class as a new component to the branch.

Since deploying components to Salesforce typically requires sufficient test coverage, the AI Test Class Creator helps accelerate test coverage by:

* Improving deployment readiness by adding missing test coverage.
* Reducing deployment failures caused by insufficient or failing tests.
* Standardizing baseline test patterns across teams.
* Accelerating delivery by reducing manual test scaffolding effort.

{% hint style="info" %}

#### Default AI Limitations

By default, Flosum provides a free shared DeepSeek AI model for DevOps through DeepSeek’s API. Because it is shared across tenants, performance and availability depend on system load and token capacity. During heavy usage, you may see higher latency or temporary errors. To avoid this, you can add your own custom AI model. See the following article.

* [Adding a Custom AI Model](/devops/settings/ai-settings/adding-a-custom-ai-model.md)
  {% endhint %}

{% hint style="info" %}

#### Best Practices

* Review the generated test data setup to ensure it matches your organization’s validation rules and required fields.
* Ensure the test class follows your team’s naming conventions and deployment standards.
* When possible, commit test classes separately to keep changes easy to review and track.
  {% endhint %}

## Using AI Test Class

{% stepper %}
{% step %}

### Select a Branch and Component

1. Click **Code** from the left sidebar menu.
2. Click the branch that contains the component you want to create a test class for.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FjPY9ZPXse212SeXyIT0f%2FUsingAiTestClass-S01-01.png?alt=media&amp;token=da2cef93-ebd4-4332-8cc7-2d2eaac9be0e" alt="" width="563"><figcaption></figcaption></figure></div>
3. Click the component you want to create a test class for.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2Fjza6xctU6Ga9NXqT9JnJ%2FUsingAiTestClass-S01-02.png?alt=media&amp;token=80ddce1e-e06e-4558-9165-41c9def68bc6" alt="" width="563"><figcaption></figcaption></figure></div>

{% endstep %}

{% step %}

### Create Test Class

{% hint style="info" %}
The generated test class will use the component name, with “**Test**” appended.
{% endhint %}

1. Click **AI Tools** next to **Edit**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FHSjGxQiwNMWzBKEu5KuC%2FUsingAiTestClass-S02-01.png?alt=media&amp;token=eaef1f22-c3e1-4745-b0f4-7713f33e7e64" alt="" width="563"><figcaption></figcaption></figure></div>
2. Click **AI Test Class** from the dropdown menu.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FI6PpJOWQlLleUqsxFuCs%2FUsingAiTestClass-S02-02.png?alt=media&amp;token=6b41dee3-7c23-41c7-b7dc-2a8541299188" alt="" width="563"><figcaption></figcaption></figure></div>
3. While the test class is being generated, **AI is generating...** is displayed.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FCMgJYvojkGCPcVmI64aO%2FUsingAiTestClass-S02-03.png?alt=media&amp;token=33c762c0-193b-4e41-8997-4ebfd30c1ab4" alt="" width="563"><figcaption></figcaption></figure></div>
4. Review the test class after it is created and make any necessary changes.
5. Click **Commit changes**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FoNg9miCVV6LrAaDY9Mi5%2FUsingAiTestClass-S02-04.png?alt=media&amp;token=936375d1-853d-4dc2-baf1-69e6b5f99c98" alt="" width="563"><figcaption></figcaption></figure></div>
6. Enter a **Commit message** in the textbox.
7. Click **Commit**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FPoDhJwlqO0OHel5v9sQ4%2FUsingAiTestClass-S02-05.png?alt=media&amp;token=3c3a80d3-0794-40d1-bfad-cd157681fdd6" alt="" width="563"><figcaption></figcaption></figure></div>
8. Once created, the new test class is added to the branch as a new component.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FtU889BsBCIFCDTmTqXWX%2FUsingAiTestClass-S02-06.png?alt=media&amp;token=da92f88a-70cf-422a-ba3f-7998fcc561dc" alt="" width="563"><figcaption></figcaption></figure></div>

{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flosum.com/devops/code/code-tools/using-ai-test-class.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
