Business-Driven Development is a collaborative approach that focuses on aligning software development with business goals through the creation of executable specifications
Translating Business-Driven Development to executable specification in gherkins
Keywords and code blocks in Gherkins specification
- Feature is to provide a high-level description of a software feature.
- Rule is to represent one business rule that should be implemented
- Scenario or Example is a concrete example that illustrates a business rule
- Scenario Outline is used to run the same Scenario multiple times, with different set of data.
- Steps are used to define scenarios. steps can be:
- Given - describe the precondition of the system
- When - describes an event, or an action
- Then - describe an expected outcome, or result
- But - describe an outcome that is not expected
- There can be multiple steps of same type in a scenario.
- Background define a set of steps that are common to all scenarios in a feature file. Execution is after each scenarios
- Hooks are blocks of code that run before or after certain events. they are defined by annotation "@Before" and "@After" annotations. these are setup() and teardown() code in the application.
Understanding components of a cucumber framework
Feature File:
- File corresponding to a feature/rule
- Can have multiple scenarios/examples, scenario outline and background.
- Annotations can be used to group tests, e.g: smoke, nightly, regression
Step definition File
- For given, when then, but steps defined in feature file, the logical code is written in a step definition file.
- Annotation @Given, @then are used to match the step definition method with the one provided in feature file
TestRunner File to execute tests
- TestRunner file defines the tests to be executed,
Components of a Test Runner File:
- Annotations: uses annotations from testing frameworks like JUnit or TestNG to define its purpose and behavior.
- Glue: specifies the package where Cucumber can find the step definitions
- Features: feature files which needs to be executed
- Plugins: defines the reporting path, tags and formatting.
References :
https://www.linkedin.com/learning/cucumber-essential-training
No comments:
Post a Comment