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.0.tar.gz (6.6 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.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: feat_behave-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 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.0.tar.gz
Algorithm Hash digest
SHA256 685f5fbbdcfa4ca602b5530987ce1dcc661cf0ba636a3092ea783219122d33d4
MD5 4a481aec3b0d7e16adc5b8ccea05f9de
BLAKE2b-256 6c57762bcba0800c2220eb54db54cbc64f7b086677352e643b5a8639f0a0dceb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feat_behave-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e51ca35f41d8dcbe47932d55e2966a7816616aa0af9ca4e6b1ae68b19a128b4b
MD5 d73763164e72a04cd70db3258d1ed42c
BLAKE2b-256 0f95325bdac66ed6fb6be5886101acf47888740173e25f327ee89618a2ba1ee6

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