---
description: How does the Test Agent work?
---

# Test Agent Workflow

### Generating Test Suggestions

To generate test suggestions, head to the snippet of code or function in the code that you want to test.

Above the relevant snippet, you will see the code lens menu from Tabnine (This will look different depending on the IDE). In Visual Studio Code, everything in the menu, aside from the word “Tabnine” itself (in JetBrains IDEs, the Tabnine logo itself), is clickable:

Tabnine | **Edit** | **Test** | **Explain** | **Document** | **Ask**

<figure><img src="https://3436682446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2qxVf5VTm3fmwP4B4Gx%2Fuploads%2FIl8j6NUCEHELdh3JhC7N%2FShowing%20Gray%20Tabnine%20Menu%20.png?alt=media&#x26;token=71cc3a29-0d2f-4c5a-a934-8017ad74324c" alt=""><figcaption></figcaption></figure>

To open the Tabnine test agent, do one of the following three things:

1. Click **Test** above the code snippet. The test widget will open to the left side of the screen (in Visual Studio).
2. Go to the Test panel next to the Chat panel
3. Write `/test` in the Chat window

As mentioned in our Chat documentation, Tabnine makes use of the full context of your requests. That includes existing testing files and open project files.

You will see a window open asking if you do or do not already have a test file. You will have the option to either locate it or select a location for generating a new one:

<figure><img src="https://3436682446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2qxVf5VTm3fmwP4B4Gx%2Fuploads%2Ffk6OZQnwkZq2zWRqfNpp%2FGenerate%20Test%20Suggestions%201.gif?alt=media&#x26;token=f2e838e7-acec-4de9-b7e2-614ead60329c" alt=""><figcaption></figcaption></figure>

#### Updating the Test Plan State / Regenerating Test Suggestions

Once you've loaded the tests you want, update the Test Plan window by hitting the cycling ⟳ symbol in the upper righthand corner of the **Test plan** window:

<figure><img src="https://3436682446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2qxVf5VTm3fmwP4B4Gx%2Fuploads%2FNI7v88eZLsCJywmdjha6%2FRegenerate%20Test%20Suggestions.gif?alt=media&#x26;token=e60c822d-d2e9-43bc-b1dd-ac880e48c50f" alt=""><figcaption></figcaption></figure>



#### Return to the Test Plan Window

At any time, you can return to the Test plan window by clicking the beaker icon between the chat icon and the Settings cog:

<figure><img src="https://3436682446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2qxVf5VTm3fmwP4B4Gx%2Fuploads%2FI0lZL7dDpGkdMAVnwwoE%2FSwitch%20Chat%20to%20Test%20GIF.gif?alt=media&#x26;token=6cdececa-7eda-4ce9-9d77-41e0e49a0e05" alt=""><figcaption></figcaption></figure>

### Insert Test Code into Test File

You will see multiple options for inserting the suggested testing code into the test file. The three options are:

1. Apply
2. Insert
3. Copy

<figure><img src="https://3436682446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2qxVf5VTm3fmwP4B4Gx%2Fuploads%2FJOmLPuaPxSAK2BjK7ZG3%2FApply%20Insert%20Copy%20Thumbs%20Up%20Thumbs%20Down.png?alt=media&#x26;token=3fb00852-d9f1-4e80-908e-1c0b0f839b0d" alt=""><figcaption></figcaption></figure>

#### Apply

Hitting "Apply" is the simplest of the options. For the test code, Tabnine will automatically place it at the end as the last segment of code in the file.&#x20;

#### Insert

Insert is somewhat more like human-in-the-loop (HITL), where you deliberately select the placement of the test code by pre-clicking the location. You will see the text cursor floating / blinking there. In this situation, you have to be sure the correct location is marked.

#### Copy

Copying the code is the most manual process. Some might prefer this when wanting to be extra precise that the code is not errantly put in the wrong place.&#x20;

Here, copy the code, _**THEN**_ navigate to where you want it, and only then finally paste it.

### Modifying Test Cases

In the text bar below the selected test, write in how you want to modify the test. After a few seconds, the regenerated test will be available.&#x20;

If you had already applied or inserted the previous version of that test into the code, Tabnine will pinpoint what to replace.

Simply press <mark style="color:blue;">**Apply**</mark>, then the new test language will appear highlighted over the previous testing language. Press Alt+A on the keyboard or **✓ Accept the change (Alt+A)** above the highlighted section to implement the new test:

<figure><img src="https://3436682446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2qxVf5VTm3fmwP4B4Gx%2Fuploads%2FaH9qhShGKFjZJULaERWC%2FApply%20and%20Accept%20Change.gif?alt=media&#x26;token=1e2b0551-1260-4857-9a61-5f9e85cde346" alt=""><figcaption></figcaption></figure>

### Adding Custom Test Cases

Below the full list of suggested tests, you can request the generation of another test.

In our example, our word game should also come up with results that uses letters more than once, so we ask Tabnine to create such a test:

<figure><img src="https://3436682446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY2qxVf5VTm3fmwP4B4Gx%2Fuploads%2FsP91iuQfNxRurStXGdES%2FTest%20for%20repeated%20letters.gif?alt=media&#x26;token=e0761cc2-925e-4507-879f-ca6679289e11" alt=""><figcaption></figcaption></figure>
