Closed Pastilhex closed 2 weeks ago
Gherkin is a structured, plain-text language designed for writing human-readable test cases. Its format uses keywords like Feature
, Scenario
, Given
, When
, Then
, And
, and But
to describe test cases in a natural language that all stakeholders can understand, including non-technical team members.
While Gherkin describes expected behavior, it does not execute tests on its own. For Gherkin files (typically .feature
files) to be executed, a BDD (Behavior-Driven Development) framework is required. BDD frameworks like Cucumber, SpecFlow, and Behave act as the engines that interpret and run Gherkin tests.
Each Gherkin step in a .feature
file is mapped to a "step definition" function within the BDD framework. When a test runs, the BDD framework reads the .feature
file, executes the mapped code, and validates outputs against the expected results. These frameworks also generate detailed reports on which scenarios passed or failed.
Summary: Gherkin is the descriptive language for test cases, while BDD frameworks make these descriptions executable, transforming them from simple documentation into an automated testing suite.
.feature
FileFeature: String manipulation
Scenario: Convert string to uppercase Given I have a command "up" And an input string "Hello world" When I run the command Then I should see the output "HELLO WORLD"
Gherkin is not a framework. It's a way to write descriptions of your tests that are readable for a non-tech person. You can then use frameworks to convert those descriptions into real tests (python, java etc...).
Doesn't look very useful in our case as everyone understands code. Up for debate.
Research gherkin framework for tests