Cucumber Migration¶
behave-gen migrate converts a Cucumber (Java) project to a Behave project
layout by copying .feature files and emitting a migration report.
Usage¶
What it does¶
- Scans the source directory for
.featurefiles (typically undersrc/test/resources/features/). - Copies each
.featurefile into the output directory, preserving the directory structure. - Reports the number of migrated files, any skipped files, and warnings about Java step definitions that need manual translation.
What it does not do¶
- Does not translate Java step definitions to Python. Java step files
(
*Steps.java) are detected and reported as a warning. Usebehave-gen add steps --lib <http|auth>to generate Python step definitions, or write them manually. - Does not convert Gherkin syntax. Cucumber and Behave both use Gherkin,
so
.featurefiles are compatible as-is. The only differences are in step definitions, not feature files.
Example¶
Source Cucumber project:
cucumber-project/
src/
test/
java/
com/
example/
LoginSteps.java
resources/
features/
login.feature
checkout.feature
Run migration:
Output:
Migrated feature migrated/features/src/test/resources/features/checkout.feature
Migrated feature migrated/features/src/test/resources/features/login.feature
Migrated 2 feature file(s).
migrate: warning: Found 1 Java step definition file(s).
Use 'behave-gen add steps --lib <http|auth>' to generate Python step definitions.
Result:
After migration¶
- Add step definitions:
- Check for undefined steps:
- Run tests:
Options¶
| Option | Default | Description |
|---|---|---|
SOURCE_DIR |
required | Cucumber project to migrate. |
--out-dir |
migrated |
Output directory for the Behave project. |