Skip to content

Generate BDD scenarios automatically using AI prompting. Prepare a foundational framework that combines Artificial Intelligence with Behavior-Driven Development (BDD) to streamline test automation.

Notifications You must be signed in to change notification settings

FaraziF/AI_BDD_BASIC_FRAMEWORK

Repository files navigation

AI_BDD_BASIC_FRAMEWORK

A Behavior-Driven Development (BDD) framework that leverages Python, Playwright, Behave, Allure, and OpenAI for automated web application testing.


Installation

  1. Clone the Repository

    git clone https://github.com/FaraziF/AI_BDD_BASIC_FRAMEWORK.git
    cd AI_BDD_BASIC_FRAMEWORK
  2. Create and Activate a Virtual Environment (Recommended)

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Dependencies

    pip install -r requirements.txt

    If requirements.txt is missing, install manually:

    pip install behave playwright allure-behave openai
  4. Install Playwright Browsers

    playwright install
  5. Set Up Configuration Files

    • Create config/openai_key.json with your OpenAI API key:
      { "api_key": "YOUR_OPENAI_API_KEY" }
    • Create config/env.json for browser settings:
      {
        "browser": "chromium",
        "headless": false
      }

Usage

1. Generating Feature Scenarios (Optional)

Automatically generate Gherkin scenarios for the "Contact Us" form:

python run_tests.py

This will generate or update features/contact_form.feature.

2. Running Tests

Execute BDD tests and generate Allure result files:

python custom_runner.py
  • Cleans/creates reports and screenshots folders.
  • Runs all scenarios tagged with @regression.
  • Outputs results to reports/allure-results.

3. Viewing Allure Reports

Generate and open the Allure HTML report:

allure generate reports/allure-results -o reports/allure-report --clean
allure open reports/allure-report

Project Structure

  • features/ - Gherkin feature files and step definitions.
  • features/steps/ - Python step implementations for Behave.
  • features/environment.py - Hooks for setup/teardown (browser, Playwright).
  • config/ - Configuration files (openai_key.json, env.json, etc).
  • utils/ - Utility modules (OpenAI integration, step analysis, types).
  • run_tests.py - Script to generate Gherkin scenarios using OpenAI.
  • custom_runner.py - Custom test runner with Allure integration.

Notes

  • Edit or add feature files in features/.
  • Step definitions are in features/steps/contact_us_form_steps.py.
  • OpenAI Integration: Used for scenario and step suggestion/generation.
  • Allure Reporting: Screenshots and test results are integrated with Allure.

Requirements


License

MIT

About

Generate BDD scenarios automatically using AI prompting. Prepare a foundational framework that combines Artificial Intelligence with Behavior-Driven Development (BDD) to streamline test automation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published