A VS Code extension for discovering, running, and debugging Behave tests with full integration into the VS Code testing framework.
.feature
files in your workspace.vsix
file from the releases pagegit clone https://github.com/your-username/behave-test-runner.git
cd behave-test-runner
npm install
npm run compile
npm run package
pip install behave
).feature
filesThe extension automatically organizes your tests in the Test Explorer with multiple organization strategies:
The extension uses Feature-Based (Hierarchical) Organization as the default strategy:
Note: The default organization strategy is set in the extension code and cannot be changed via configuration. You can switch between strategies using the context menu in the Test Explorer.
@smoke
, @regression
)Switch Organization: Right-click in the Test Explorer → "Organization Strategy" → Choose your preferred organization strategy
The extension provides enhanced support for scenario outlines:
When you open a .feature
file, you'll see inline buttons above each scenario:
Note: Right click on play button will give additional options like debugging test
Command | Description |
---|---|
Behave: Discover Tests |
Manually discover and load test files |
Behave: Refresh Tests |
Refresh and reload all test files |
Behave: Run All Tests |
Run all tests in the workspace |
Behave: Run All Tests in Parallel |
Run all tests in parallel for faster execution |
Behave: Run Scenario |
Run a specific scenario (used by CodeLens) |
Behave: Debug Scenario |
Debug a specific scenario (used by CodeLens) |
Behave: Run Feature File |
Run an entire feature file |
Behave: Run Feature File with Tags |
Run a feature file with specific tags |
Setting | Default | Description |
---|---|---|
behaveTestRunner.behaveCommand |
"behave" |
Command to run Behave tests (auto-detects Python if needed) |
behaveTestRunner.workingDirectory |
"" |
Working directory for test execution (empty = workspace root) |
behaveTestRunner.autoDiscoverTests |
true |
Automatically discover tests on startup |
behaveTestRunner.testFilePattern |
"**/*.feature" |
Glob pattern for test file discovery |
behaveTestRunner.enableCodeLens |
true |
Enable CodeLens buttons on feature files (disable if conflicting with other extensions) |
behaveTestRunner.enableTestExplorer |
true |
Enable Test Explorer integration (disable if conflicting with other test explorers) |
behaveTestRunner.priority |
"normal" |
Extension priority for handling feature files (use 'low' if other extensions should take precedence) |
behaveTestRunner.parallelExecution |
false |
Enable parallel execution of feature files |
behaveTestRunner.maxParallelProcesses |
4 |
Maximum number of parallel processes for test execution |
behaveTestRunner.outputFormat |
"pretty" |
Output format for behave test results (pretty, plain, json, junit, progress, steps) |
behaveTestRunner.tags |
"" |
Default tags to filter tests (e.g., '@smoke,@regression') |
behaveTestRunner.dryRun |
false |
Enable dry run mode to see what tests would be executed without running them |
The extension automatically detects the correct Python command for your system:
python3
, python
, then py
py
, python
, then python3
python3 -m behave
if direct behave
command is not availableYou can override this by setting a specific command in your configuration.
{
"behaveTestRunner.behaveCommand": "python3 -m behave",
"behaveTestRunner.workingDirectory": "${workspaceFolder}/tests",
"behaveTestRunner.autoDiscoverTests": true,
"behaveTestRunner.testFilePattern": "**/features/**/*.feature",
"behaveTestRunner.enableCodeLens": true,
"behaveTestRunner.enableTestExplorer": true,
"behaveTestRunner.priority": "normal",
"behaveTestRunner.parallelExecution": false,
"behaveTestRunner.maxParallelProcesses": 4,
"behaveTestRunner.outputFormat": "pretty",
"behaveTestRunner.tags": "@smoke,@regression",
"behaveTestRunner.dryRun": false
}
Basic Scenario Outline:
@feature @login
Feature: User Login
@smoke @critical
Scenario Outline: Login with different credentials
Given I am on the login page
When I enter username "<username>" and password "<password>"
And I click the login button
Then I should see "<expected_result>"
Examples:
| username | password | expected_result |
| admin | admin123 | dashboard |
| user | user123 | dashboard |
| invalid | wrong | error message |
Multiple Scenario Outlines:
@feature @api
Feature: API Testing
@api @validation
Scenario Outline: Data validation with various inputs
Given I have a valid API endpoint
When I send "<data_type>" data with value "<input_value>"
Then the response should contain "<validation_result>"
Examples:
| data_type | input_value | validation_result |
| string | hello | valid |
| number | 42 | valid |
| email | test@test | invalid |
@performance @load
Scenario Outline: Load testing with different user loads
Given I have configured the load testing environment
When I simulate "<concurrent_users>" concurrent users
Then the system should handle the load successfully
Examples:
| concurrent_users |
| 10 |
| 50 |
| 100 |
In the Test Explorer, these will appear as:
Feature-Based (Hierarchical) Organization (Default):
Tag-Based Organization:
This extension is designed to work alongside other VS Code Gherkin extensions.
Note: This extension is developed and tested with Cucumber (Gherkin) Full Support extension. Since you're using Cucumber (Gherkin) Full Support for syntax highlighting and autocomplete, this extension focuses on test execution and discovery. The extensions complement each other perfectly:
{
"behaveTestRunner.enableCodeLens": true,
"behaveTestRunner.enableTestExplorer": true,
"behaveTestRunner.priority": "low",
"behaveTestRunner.defaultOrganizationStrategy": "FeatureBasedOrganization"
}
Why this works well:
The priority
setting determines which extension takes precedence when multiple extensions can handle the same file type:
"low"
: Let other extensions handle .feature
files first"normal"
: Standard priority"high"
: Take precedence over other extensionssrc/
├── core/ # Core functionality
│ └── test-executor.ts # Test execution logic
├── parsers/ # File parsing
│ └── feature-parser.ts # Gherkin feature file parser
├── test-providers/ # VS Code test integration
│ └── behave-test-provider.ts
├── commands/ # VS Code commands
│ └── command-manager.ts # Command registration and handling
├── utils/ # Utilities
│ └── logger.ts # Logging utility
├── types/ # TypeScript type definitions
│ └── index.ts # Shared interfaces and types
└── extension.ts # Main extension entry point
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Run tests
npm test
# Package extension
npm run package
Script | Description |
---|---|
npm run compile |
Compile TypeScript and build extension |
npm run watch |
Watch for changes and recompile |
npm run lint |
Run ESLint |
npm run lint:fix |
Fix ESLint issues |
npm test |
Run all tests |
npm run package |
Create VSIX package |
npm run package:vsix |
Create VSIX package with version |
npm run dev |
Start development mode |
npm run test:unit |
Run unit tests only |
npm run test:integration |
Run integration tests only |
npm run test:parser |
Run parser tests only |
npm run test:execution |
Run execution tests only |
The extension includes comprehensive tests:
Current Test Status: 111 tests passing, 1 failing (33 lint warnings in source files only)
Run tests with:
npm test # Run all tests
npm run test:unit # Run unit tests only
npm run test:integration # Run integration tests only
npm run test:parser # Run parser tests only
npm run test:execution # Run execution tests only
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)Tests not discovered:
.feature
files exist in your workspacetestFilePattern
settingTests not running:
behave --version
)behaveCommand
settingDebug not working:
Enable detailed logging by opening the Output panel (View → Output) and selecting "Behave Test Runner" from the dropdown.
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a list of changes and version history.
"Code, coffee, repeat. Support the cycle! : If you enjoy using Behave Test Runner, consider contributing to fuel my coding dreams!