GoGherkinRunner helps you run and debug individual Gherkin scenarios in Go projects directly from VS Code. It is designed for teams working with .feature files and Go test integration, making it easy to execute or debug a single scenario with one click.
- CodeLens Buttons: Above every
Scenario:line in.featurefiles, you get:▶️ Run test: Runs only that scenario using your Go test setup.- 🐞 Debug (Scenario N): Launches the VS Code debugger for that specific scenario, with all required environment variables.
- Terminal Integration: Runs the Go test command in the integrated terminal, matching your project’s structure and environment.
- Debug Integration: Launches a Go debug session with the correct
-test.runand-dotenv-dirarguments. - Automatic Project Path Detection: Dynamically finds the correct Go package and environment directory for each scenario.
- Go extension for VS Code
- Your Go project must use
.featurefiles and have test functions that map to those features. - Environment variables should be set via a
.envfile in yourservicedirectory.
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X) - Search for "Go Gherkin Runner"
- Click "Install"
- Build the extension:
This creates a
npm install npm run compile vsce package
.vsixfile (e.g.,GoGherkinRunner-0.0.4.vsix). - In VS Code, open the Command Palette (
Ctrl+Shift+P), selectExtensions: Install from VSIX..., and choose your.vsixfile.
- Clone the repo, run
npm install, then pressF5in VS Code to launch a development window.
- Open a
.featurefile in your Go project. - You will see CodeLens buttons above each
Scenario:line:▶️ Run test: Runs the scenario in the terminal.- 🐞 Debug (Scenario N): Starts a debug session for that scenario.
- You can also run the commands manually:
GoGherkinRunner: Run Single ScenarioGoGherkinRunner: Debug Single Scenario
- The extension parses the
.featurefile, finds the corresponding Go test function, and constructs the correct test command. - It automatically finds the
servicedirectory for environment variables. - Debugging uses the Go extension’s debug adapter with the right arguments for single-scenario execution.
- No CodeLens buttons?
- Make sure your file is recognized as
featureorgherkin(see the language mode in the status bar). - Ensure CodeLens is enabled in VS Code settings.
- Make sure your file is recognized as
- Debug session fails with missing env?
- Check that your
.envfile exists in theservicedirectory and contains all required variables.
- Check that your
- Go test not found?
- Make sure your Go test files reference the feature file name.
Pull requests and suggestions are welcome!
MIT