Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
662 changes: 662 additions & 0 deletions .github/copilot-instructions.md

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions examples/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cucumber-eclipse-examples</name>
<comment></comment>
<projects>
</projects>
<buildSpec>

</buildSpec>
<natures>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions examples/python-calculator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
*.pyc
*.pyo
.pytest_cache/
12 changes: 12 additions & 0 deletions examples/python-calculator/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>python-caclulator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>

</buildSpec>
<natures>
</natures>
</projectDescription>
69 changes: 69 additions & 0 deletions examples/python-calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Python Calculator Example

This is a simple example demonstrating how to use the Cucumber-Behave launcher with Eclipse.

## Prerequisites

1. Python 3.x installed
2. Behave package installed:
```bash
pip install behave
```

## Running the Example

### From Command Line

```bash
cd examples/python-calculator
behave
```

### From Eclipse

1. Open Eclipse with Cucumber Eclipse plugin installed
2. Import this project into Eclipse
3. Right-click on `features/calculator.feature`
4. Select "Run As" > "Cucumber-Behave"
5. In the launch configuration dialog:
- **Feature Path**: Select the `calculator.feature` file
- **Working Directory**: Set to the `examples/python-calculator` directory
- **Python Interpreter**: Use `python` or `python3` depending on your system
- Click "Run"

## Project Structure

```
python-calculator/
├── features/
│ ├── calculator.feature # Feature file with scenarios
│ └── steps/
│ └── calculator_steps.py # Step definitions
└── README.md
```

## Expected Output

When you run the tests, you should see output indicating that all three scenarios pass:

```
Feature: Calculator # features/calculator.feature:1

Scenario: Add two numbers # features/calculator.feature:6
Given I have a calculator # features/steps/calculator_steps.py:19
When I add 2 and 3 # features/steps/calculator_steps.py:23
Then the result should be 5 # features/steps/calculator_steps.py:35

Scenario: Subtract two numbers # features/calculator.feature:11
Given I have a calculator # features/steps/calculator_steps.py:19
When I subtract 3 from 5 # features/steps/calculator_steps.py:27
Then the result should be 2 # features/steps/calculator_steps.py:35

Scenario: Multiply two numbers # features/calculator.feature:16
Given I have a calculator # features/steps/calculator_steps.py:19
When I multiply 2 by 3 # features/steps/calculator_steps.py:31
Then the result should be 6 # features/steps/calculator_steps.py:35

3 scenarios (3 passed)
9 steps (9 passed)
```
19 changes: 19 additions & 0 deletions examples/python-calculator/features/calculator.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Calculator
As a user
I want to use a calculator
So that I can perform basic arithmetic operations

Scenario: Add two numbers
Given I have a calculator
When I add 2 and 3
Then the result should be 5

Scenario: Subtract two numbers
Given I have a calculator
When I subtract 3 from 5
Then the result should be 2

Scenario: Multiply two numbers
Given I have a calculator
When I multiply 2 by 3
Then the result should be 6
38 changes: 38 additions & 0 deletions examples/python-calculator/features/steps/calculator_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from behave import given, when, then

class Calculator:
def __init__(self):
self.result = 0

def add(self, a, b):
self.result = a + b
return self.result

def subtract(self, a, b):
self.result = a - b
return self.result

def multiply(self, a, b):
self.result = a * b
return self.result

@given('I have a calculator')
def step_impl(context):
context.calculator = Calculator()

@when('I add {a:d} and {b:d}')
def step_impl(context, a, b):
context.calculator.add(a, b)

@when('I subtract {a:d} from {b:d}')
def step_impl(context, a, b):
context.calculator.subtract(b, a)

@when('I multiply {a:d} by {b:d}')
def step_impl(context, a, b):
context.calculator.multiply(a, b)

@then('the result should be {expected:d}')
def step_impl(context, expected):
assert context.calculator.result == expected, \
f"Expected {expected}, but got {context.calculator.result}"
4 changes: 4 additions & 0 deletions io.cucumber.eclipse.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
id="io.cucumber.eclipse.java.plugins"
version="0.0.0"/>

<plugin
id="io.cucumber.eclipse.python"
version="0.0.0"/>

</feature>
7 changes: 7 additions & 0 deletions io.cucumber.eclipse.python/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions io.cucumber.eclipse.python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
33 changes: 33 additions & 0 deletions io.cucumber.eclipse.python/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>io.cucumber.eclipse.python</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=21
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
classpath=true
dsVersion=V1_3
eclipse.preferences.version=1
enabled=true
generateBundleActivationPolicyLazy=true
path=OSGI-INF
validationErrorLevel=error
validationErrorLevel.missingImplicitUnbindMethod=error
Loading