> For the complete documentation index, see [llms.txt](https://docs.walnutai.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.walnutai.ai/core-features/intelligence-hub/generate-test-cases/code-repository-to-test-case.md).

# Code (Repository-to-Test Case)

**When to Use Code Repository Analysis:**\
Use this feature when you want to generate test cases by analysing code from connected repositories. Walnut AI scans the repository, understands the application logic, and helps generate structured test cases.

**Steps to Generate:**

* **Select Code Repository:** Click **Code** under **Generate Test Cases**.

<figure><img src="/files/ALdtmMPEBHtcE9CI6uvQ" alt=""><figcaption></figcaption></figure>

* **Connect Repository:** If no repositories are connected, click **Add Repo** to navigate to the **Connect Repository** page and link your Git provider. If the project does not have an Code Repository tools connected, you will be automatically redirected to setup the [Code Repository platform integration with WalnutAI ](/getting-started/projects/create-a-new-project/external-data-and-connections.md)so that you can connect with your code repository.

<figure><img src="/files/xMQpvrUInq8IbXNxcbco" alt=""><figcaption></figcaption></figure>

* **Choose Repository:** Select one or more connected repositories and click **Add Selected Repositories**.

<figure><img src="/files/AZjRr5x5ijZz4iF5U0cT" alt=""><figcaption></figcaption></figure>

* **Discover Modules:** Walnut AI scans the repository and identifies logical modules based on the repository structure and code patterns.

<figure><img src="/files/HFNotKp72mJ5nOd72M3c" alt=""><figcaption></figcaption></figure>

* **Select Modules:** Choose the relevant modules you want to analyze and click **Continue to Chat**.

<figure><img src="/files/14dHIwcv8BJ7GHx6uvA5" alt=""><figcaption></figcaption></figure>

* **Generate Test Cases:** Use the **Walnut AI Chatbot** to generate test cases by providing prompts such as *generate functional test cases*, *create API test cases*, or *add negative scenarios*.

<figure><img src="/files/yL6uCfFwsRod2ymt7ZIu" alt=""><figcaption></figcaption></figure>

* **Review & Refine:** You can modify generated steps, add validations, improve scenarios, or refine the test cases using the chatbot.

<figure><img src="/files/LMhCc03rHNk9p6aA0POV" alt=""><figcaption></figcaption></figure>

* **Save:** Click **Save** to retain the generated test cases. If not saved, the generated test cases will not be retained.

<figure><img src="/files/3F4jXbf1omtPFqETdhss" alt=""><figcaption></figcaption></figure>

**Download & Repository Management:** Generated test cases can be downloaded for reference, and repositories can be managed from the **Connect Repository** page.\
Analyse connected code repositories to generate structured, execution-ready test cases.

{% hint style="info" %}
**Result:** Saved **Test Cases** will appear in the **Test Case Module** reflected accordingly.
{% endhint %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.walnutai.ai/core-features/intelligence-hub/generate-test-cases/code-repository-to-test-case.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
