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.1.tar.gz (7.2 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.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: feat_behave-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 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.1.tar.gz
Algorithm Hash digest
SHA256 26e7e97eceb98e3da1b13b3f1aa8a6375b0867d0dcb7a0b7c8ef00be13c2b2f8
MD5 e0624bd10fb93ad5391b30dd6248cfa3
BLAKE2b-256 e46ed0b53078864c6f20ac01983ccaa0ddf796cb718ace79975f1c9435cb6112

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feat_behave-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3fa583e0baf60cfccaab3d1283835f5d60cfcbb542ebd3e12c690dae81ba0764
MD5 9fb1ce988c9f113bca00ddfb10e6f7c8
BLAKE2b-256 69902109c58c78ad17bb3ab0c0d287404624f5fbf99243ad60ead31731106107

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