I am new to the Cucumber framework. I am trying to make Cucumber work with Python. I have written the feature file and want to know how to write the step definitions in Python.
I searched over the internet and found the step definitions for Ruby language but nothing for Python. Is it even possible to run Cucumber with Python?
Check out behave, behaviour-driven development library, Python style.
It doesn't use Cucumber, but you can reuse
.feature
files because they use the same Gherkin language.Sample behave's step definition:
Cucumber supports 14 languages right now, including Python on the JVM also called Jython.
I would start by reading up on Cucumber-JVM, it is an implementation of Cucumber for the JVM. To use the Java 6/7 so you can use the Cucumber API. You need to write Python methods with Java annotations, to tell Cucumber which regexes correlate with each method.
This sounds like a lot of indirection, but it is fairly straight forward:
Gherkin:
Python/Jython:
This was copied from the cucumber reference page in the corner of each code sample (not gherkin, but step definition), you can select the language of you choice.
The documentation is incomplete, but where it is complete it is useful. It does include the entry for your maven config if you are using that and most of the information needed for basic use. Any documentation you find elsewhere on the web for cucumber in Java should work with Jython as long as you are familiar with calling Java from Jython.