Skip to main content

AI automated test generation

Project description

test-ai-leds is the python package that powers the Test.AI VS code extension

Test.AI Extension for VS Code

Test.AI is a powerful Visual Studio Code extension designed to simplify the process of creating Behavior-Driven Development (BDD) tests for software. By leveraging generative AI and agents, Test.AI converts .andes files into Gherkin .feature files and auto-generates corresponding step definitions. This automation significantly reduces the time and effort required to develop comprehensive BDD tests.

Features

  • Conversion of .andes Files to Gherkin: Automatically transforms user stories described in .andes files into Gherkin .feature files.
  • Step Definition Generation: Generates step definitions for the .feature files to streamline test development. Currently, step definitions are generated exclusively for C#, with plans to support additional languages in the future.
  • AI-Powered Automation: Utilizes large language models (LLMs) to ensure high-quality and context-aware test generation.
  • Seamless Integration: Works directly within Visual Studio Code, providing a smooth development experience.

Installation

  1. Open Visual Studio Code.
  2. Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or pressing Ctrl+Shift+X.
  3. Search for Test.AI.
  4. Click Install.

Getting Started

Prerequisites

  • Python
  • Python package test-ai-leds
  • .andes files describing user cases in the expected format.
  • An active internet connection for AI-based generation.
  • A .env file in the root folder of your VS Code project containing the following variables:
    • DTO_SOURCE: The full path to the DTO files directory in your project.
    • SWAGGER_PATH: The full path to the Swagger document of your project.
    • LLM_MODEL: The AI model chosen by the user.
    • API_KEY: The API key for the AI model being used.

Setup

First you need to install test-ai-leds by running pip install test-ai-leds in the terminal. You can either install globally or in a virtual environment.

It is also necessary to add the Python package scripts directory to the PATH environment variable. Below is an explanation of how to do this:

  • Windows:

    • Run pip show test-ai-leds in the terminal.
    • Some information will be returned, including the location of the installed packages. It will look something like: C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages
    • You just need to change the last directory from site-packages to Scripts. For example: C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts
    • Add this path to your environment variables.
    • Note: The same can be done using Python virtual environments if you do not want to install the library globally. In that case, the Scripts path will be relative to the venv folder.
  • Linux:

    • Linux does not allow global installations of Python packages. Therefore, you need to create a virtual environment using the command:
      python -m venv <venv_name>
    • Activate the venv with:
      source <path_to_venv>/bin/activate
    • Run: pip install test-ai-leds
    • The scripts path on Linux is usually: <path_to_venv>/bin
    • Run: nano ~/.bashrc and add the following at the end of the file: export PATH=$PATH:/<path_to_your_venv>/bin
    • Finally, run: source ~/.bashrc to apply the changes.

Usage

  1. Open a .andes file in Visual Studio Code.
  2. Right-click on the file and select Generate BDD Tests with Test.AI.
  3. The extension will:
    • Create a corresponding .feature file in the same directory.
    • Generate step definitions and save them in a designated folder (steps/ by default).
  4. Review and refine the generated tests as needed.

Example

Input (example.andes):

[User Story]
As a user, I want to log in to my account so that I can access my dashboard.

[Acceptance Criteria]
- Given I am on the login page
- When I enter my username and password
- And I click the login button
- Then I should see the dashboard.

Output (features/example.feature):

Feature: User Login

  Scenario: Successful login
    Given I am on the login page
    When I enter my username and password
    And I click the login button
    Then I should see the dashboard.

Generated Step Definitions (steps/exampleSteps.cs):

using TechTalk.SpecFlow;

[Binding]
public class ExampleSteps
{
    [Given("I am on the login page")]
    public void GivenIAmOnTheLoginPage()
    {
        // Add implementation here
    }

    [When("I enter my username and password")]
    public void WhenIEnterMyUsernameAndPassword()
    {
        // Add implementation here
    }

    [When("I click the login button")]
    public void WhenIClickTheLoginButton()
    {
        // Add implementation here
    }

    [Then("I should see the dashboard")]
    public void ThenIShouldSeeTheDashboard()
    {
        // Add implementation here
    }
}

Happy Testing! 🚀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

test_ai_leds-0.1.5.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

test_ai_leds-0.1.5-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file test_ai_leds-0.1.5.tar.gz.

File metadata

  • Download URL: test_ai_leds-0.1.5.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for test_ai_leds-0.1.5.tar.gz
Algorithm Hash digest
SHA256 03aceb0a1c46a070b1c9b4a2ded6143ca06856a05e70f39fa12606d0dd6a8f86
MD5 a744c302e12634b404e9507991b7f413
BLAKE2b-256 95ee3b3d5dfebb26aec92d5474d2d96b37fd2d256426a7af07a3596253505111

See more details on using hashes here.

File details

Details for the file test_ai_leds-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: test_ai_leds-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for test_ai_leds-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 25b6324b2190799ab94c1b121d4d5ef15a7e88132f7e76516558c087149e9318
MD5 8de7bb6b261808d69a491f126a6131f6
BLAKE2b-256 ccfb8a6c8533030aef8e366c61f1083844bad85e8e6843a4e3390eaba23d54da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page