Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 20, 2025

This PR implements a new Eclipse plugin bundle io.cucumber.eclipse.python that enables launching Cucumber feature files using Python's Behave framework, addressing the requirements outlined in the issue.

Overview

Following the architecture of the existing io.cucumber.eclipse.java bundle, this implementation provides a complete Eclipse launch configuration for executing Cucumber feature files with Python/Behave. Users can now right-click on .feature files in Python projects and run them using the existing "Cucumber" context menu option.

What's Implemented

Core Launch Framework

  • Launch Configuration Type: Defines a new launch configuration type cucumber.eclipse.python.launching.localCucumberBehave for running feature files with Behave
  • Launch Delegate: CucumberBehaveLaunchConfigurationDelegate creates and manages Python processes, builds Behave commands with appropriate flags and options
  • Launch UI: Complete configuration interface with tabs for:
    • Feature file selection with file browser
    • Working directory configuration
    • Python interpreter path
    • Tag expression filtering
    • Behave options (verbose, no-capture, dry-run)

Eclipse Integration

  • ILauncher Implementation: Implements the ILauncher interface from the editor bundle, following the same pattern as CucumberRuntimeLauncher in the Java bundle
  • OSGi Service Component: Registered as an OSGi Declarative Service for automatic discovery by the editor's launch framework
  • Context Menu Integration: Integrates with the editor's existing CucumberFeatureLaunchShortcut - users right-click on feature files and select "Run As > Cucumber"
  • Automatic Project Detection: Detects Python projects by checking for PyDev nature, requirements.txt, setup.py, pyproject.toml, and virtual environment folders
  • Automatic Configuration: Creates and manages launch configurations automatically when invoked from context menu
  • Optional PyDev Support: Soft dependency on PyDev plugins (marked as optional) for future integration without requiring PyDev installation

Bundle Structure

io.cucumber.eclipse.python/
├── META-INF/MANIFEST.MF          # Bundle metadata and dependencies
├── plugin.xml                     # Extension point declarations
├── build.properties              # Maven/Tycho build configuration
├── OSGI-INF/                      # OSGi service descriptors
│   └── CucumberBehaveLauncher.xml
├── src/
│   └── io/cucumber/eclipse/python/
│       ├── Activator.java        # Bundle activator
│       └── launching/
│           ├── CucumberBehaveLaunchConfigurationDelegate.java
│           ├── CucumberBehaveLaunchConstants.java
│           ├── CucumberBehaveLauncher.java  # ILauncher implementation
│           ├── CucumberBehaveMainTab.java
│           └── CucumberBehaveTabGroup.java
├── README.md                      # User documentation
└── IMPLEMENTATION.md             # Technical documentation

Example Project

Added examples/python-calculator/ demonstrating complete usage:

  • Feature file with calculator scenarios (add, subtract, multiply)
  • Python step definitions using Behave
  • README with setup instructions and expected output

Key Features

  • ✅ Executes Cucumber feature files using Behave
  • ✅ Configurable Python interpreter (defaults to python)
  • ✅ Working directory configuration for project context
  • ✅ Tag-based scenario filtering
  • ✅ Support for Behave command-line options
  • ✅ Implements ILauncher interface for seamless editor integration
  • ✅ Registered as OSGi service component for automatic discovery
  • ✅ Context menu integration via editor's existing launch shortcut
  • ✅ Automatic launch configuration management
  • ✅ Follows Eclipse plugin best practices

Design Decisions

  1. Standalone Bundle: Created as an independent bundle rather than extending the Java bundle for cleaner separation and easier maintenance
  2. ILauncher Implementation: Implements the ILauncher interface to integrate with the editor's launch framework, following the pattern established by CucumberRuntimeLauncher
  3. OSGi Service Registration: Uses OSGi Declarative Services (@Component annotation) for automatic registration and discovery by CucumberServiceRegistry
  4. Simple Process Execution: Uses standard ProcessBuilder for direct Behave execution without complex dependencies
  5. Optional PyDev: Marked as optional dependency to allow the bundle to function independently while enabling future integration
  6. Minimal Scope: Focuses on core launch functionality as a foundation for future enhancements (debugging, step navigation, etc.)

Integration

  • Added io.cucumber.eclipse.python module to parent pom.xml
  • Included in io.cucumber.eclipse.feature/feature.xml for distribution
  • Follows the same structure and patterns as io.cucumber.eclipse.java
  • Integrates with editor's existing CucumberFeatureLaunchShortcut via ILauncher interface

Testing

The implementation can be tested by:

  1. Installing the plugin in Eclipse
  2. Creating a Python project with Behave installed (pip install behave)
  3. Creating a .feature file
  4. Right-clicking and selecting "Run As > Cucumber" (or "Cucumber Feature")

The Python/Behave launcher will automatically be used for Python projects. The included example project can be used for verification.

Future Enhancements

This implementation provides a solid foundation for future features:

  • Debug support with breakpoints in step definitions
  • PyDev integration for interpreter configuration
  • Step definition navigation and auto-completion
  • Test results view integration
  • Advanced Behave formatters (JSON, JUnit XML)

Closes #[issue-number]

Original prompt

Implement a new bundle that launches a cucumber-feature wile using behave

In PR #564 we add Pydev to the target platform and we have a first example with python in PR #568

What we now need is:

  1. a new bundle io.cucumber.eclipse.python
  2. it should contain the required methods to launch a pythong process at best reusing what pydev (https://www.pydev.org/) already offfers
  3. that then uses behave (https://behave.readthedocs.io/en/latest/) to execute a cucumer-feature file that uses pytho for its glue-code

One might look at the java implementation (io.cucumber.eclipse.java) as a blueprint that already defines org.eclipse.debug.core.launchConfigurationTypes to launch them as "Cucumber-JVM" and we need similar now described as "Cucumber-Behave" to be able to launch it with python/behave


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Add new bundle for launching Cucumber feature with Behave Implement io.cucumber.eclipse.python bundle for Cucumber-Behave launcher Oct 20, 2025
@Copilot Copilot AI requested a review from laeubi October 20, 2025 12:59
Copilot finished work on behalf of laeubi October 20, 2025 12:59
@laeubi laeubi marked this pull request as ready for review October 20, 2025 14:28
@laeubi
Copy link
Contributor

laeubi commented Oct 20, 2025

@copilot currently the phython behave defines an own launchshortcut, that is not what we want, instead it should implement the io.cucumber.eclipse.editor.launching.ILauncher interface like the CucumberRuntimeLauncher does to perform its work.

Copy link
Author

Copilot AI commented Oct 20, 2025

@copilot currently the phython behave defines an own launchshortcut, that is not what we want, instead it should implement the io.cucumber.eclipse.editor.launching.ILauncher interface like the `Cucu...

Done! I've refactored the implementation to use the ILauncher interface instead of a custom launch shortcut.

Changes in commit 5ea1efb:

  • Removed CucumberBehaveLaunchShortcut class and its extension from plugin.xml
  • Created CucumberBehaveLauncher implementing ILauncher interface
  • Registered as OSGi service component via @Component annotation and OSGI-INF descriptor
  • Now integrates with the editor's existing CucumberFeatureLaunchShortcut
  • Follows the same pattern as CucumberRuntimeLauncher in the Java bundle

The launcher is automatically discovered by CucumberServiceRegistry.getLauncher() and used when right-clicking feature files in Python projects.

Copilot finished work on behalf of laeubi October 20, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants