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
- Type
feat - Press
Tabto see available feature files - Start typing the file name and press
Tabagain 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
- Detects Active File: When you run
feat, it tries to detect which file is currently active in VS Code - Finds Directory: It extracts the directory path of the active file
- Changes Directory: Automatically
cds to that directory - Runs Behave: Executes
behave feature_file.featurein that directory - 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:
- Installed argcomplete:
pip install argcomplete - Activated global completion:
activate-global-python-argcomplete --user - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
685f5fbbdcfa4ca602b5530987ce1dcc661cf0ba636a3092ea783219122d33d4
|
|
| MD5 |
4a481aec3b0d7e16adc5b8ccea05f9de
|
|
| BLAKE2b-256 |
6c57762bcba0800c2220eb54db54cbc64f7b086677352e643b5a8639f0a0dceb
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e51ca35f41d8dcbe47932d55e2966a7816616aa0af9ca4e6b1ae68b19a128b4b
|
|
| MD5 |
d73763164e72a04cd70db3258d1ed42c
|
|
| BLAKE2b-256 |
0f95325bdac66ed6fb6be5886101acf47888740173e25f327ee89618a2ba1ee6
|