Skip to main content

Run behave feature files from VS Code with 'feat' command

Project description

auto-behave 🧪

Run behave feature files directly from VS Code's active tab with intelligent auto-completion!

Features

Automatic Directory Detection - Detects the active file in VS Code and runs behave from that directory
Tab Completion - Auto-complete feature file names by pressing Tab
🎯 Simple Command - Just type feat feature_file.feature
🔄 Fallback Support - Uses current directory if VS Code detection fails

Installation

1. Install the package

pip install -e .

2. Enable tab completion

For PowerShell (Windows)

Add this to your PowerShell profile:

# Register argcomplete for auto-behave
Register-ArgumentCompleter -Native -CommandName auto-behave -ScriptBlock {
    param($wordToComplete, $commandAst, $cursorPosition)
    $env:_ARGCOMPLETE = 1
    $env:_ARGCOMPLETE_COMP_WORDBREAKS = ' '
    $env:COMP_LINE = $commandAst.ToString()
    $env:COMP_POINT = $cursorPosition
    auto-behave 2>&1 | ForEach-Object { $_ }
}

To find your PowerShell profile location, run:

echo $PROFILE

For Bash (Linux/Mac)

Add this to your ~/.bashrc or ~/.bash_profile:

eval "$(register-python-argcomplete auto-behave)"

For Zsh (Linux/Mac)

Add this to your ~/.zshrc:

eval "$(register-python-argcomplete auto-behave)"

Usage

Basic Usage

# Run a feature file (auto-detects directory from VS Code active tab)
feat my_feature.feature

With Tab Completion

  1. Type feat
  2. Press Tab to see available feature files
  3. Start typing the file name and press Tab again to auto-complete

With Behave Arguments

# Run with tags
auto-behave my_feature.feature --tags=@smoke

# Run with specific scenario
auto-behave my_feature.feature --name="User login"

# Dry run
auto-behave my_feature.feature --dry-run

Specify Custom Directory

# Use a specific directory instead of auto-detection
auto-behave my_feature.feature -d /path/to/features

How It Works

  1. Detects Active File: When you run feat, it tries to detect which file is currently active in VS Code
  2. Finds Directory: It extracts the directory path of the active file
  3. Changes Directory: Automatically cds to that directory
  4. Runs Behave: Executes behave feature_file.feature in that directory
  5. Returns: Changes back to your original directory

Requirements

  • Python 3.6+
  • behave (for running tests)
  • argcomplete (for tab completion)
  • VS Code (optional, falls back to current directory)

Troubleshooting

"behave command not found"

Install behave:

pip install behave

Tab completion not working

Make sure you:

  1. Installed argcomplete: pip install argcomplete
  2. Activated global completion: activate-global-python-argcomplete --user
  3. Restarted your shell or ran source ~/.bashrc (or equivalent)

VS Code active file not detected

The tool will automatically fall back to using your current working directory. You can also specify a directory manually with the -d flag.

Development

Install in development mode

pip install -e .

Run tests

# Add tests here when created
pytest

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

feat_behave-0.1.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

feat_behave-0.1.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file feat_behave-0.1.2.tar.gz.

File metadata

  • Download URL: feat_behave-0.1.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for feat_behave-0.1.2.tar.gz
Algorithm Hash digest
SHA256 53240c3a93278cbb6bab85ae63bbbaaf8399ea22ef8b81e3fcf82dc12adc9584
MD5 9c59ad8a5706de5a2f07db95ea55276a
BLAKE2b-256 4470d4850cda0a6c0b5b02ab60cc7b6e0cac341446166d9af82e4c899d3391a9

See more details on using hashes here.

File details

Details for the file feat_behave-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: feat_behave-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for feat_behave-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a51c2f497d465acf6905427cfcab556f9bec3f5096ddb3459dadbcc447b6d62f
MD5 77d6babd803ba311c05e6dc012c64786
BLAKE2b-256 2e31e2859f4a3d3544f8d09534e74d42f3c2b46a81a1a1b33b9387f3f4fc67ec

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