“Profound things are simple. If it is not simple then it cannot be true. But simple things are difficult”
This quote is absolutely true for BDD as a methodology and tools implementing it as well. But most of the times we tend to lose the essence of even simple things by not focussing on the fine prints. In any BDD project, feature files are the essence of overall implementation, and this very fact gets lost in the drive to implement the definitions beneath it. In this article, we discuss some of the BDD writing Guidelines and Best Practices.
A poorly written feature file serves no purpose, rather it sets up the project for increased complexity, maintenance, overall development effort and eventually loses the goal of quality deliverables with behavioral feedback.
Unless a team sets out with common goal, proper guidelines and strict review checklists, it is very likely to have:
- Features without proper functionality focus
- Repeated and redundant steps
- Lengthy scenarios leading to
— Increased execution time
— Increased flakiness
Behavior-driven development is an “outside-in” methodology. It starts at the outside by identifying business outcomes and then drills down into the feature set that will achieve those outcomes. Each feature is captured as a “story”, which defines the scope of the feature along with its acceptance criteria. – DAN NORTH & ASSOCIATES
At Veltris, we follow certain guidelines for each step of automation development, whether it is writing feature files the right way or removing the smell from code. Below are some of the questions which our developers ask before authoring any feature file:
- Is a feature file aligned with one finite quantum of application functionality?
- Does it articulate the purpose of feature very clearly?
- Does it contain enough testing points/scenarios?
- Is background complementing all the scenarios?
- Is background not having too many steps?
- Is background independent from different inputs?
- Are scenarios related to concerned feature only?
- Will scenarios not take more than few minutes[maximum 5 minutes] to execute?
- Are scenarios independent from each other?
- Are scenarios being written from the user’s perspective?
- Does example table have enough data sets to check all conditions?
- Are examples being tagged for future executions?
- Are steps generic in nature?
- Are steps utilizing data tables to reduce the number of similar actions?
- Are steps utilizing keywords [Given, When, Then, But] appropriately?
If you have thought about various implications of the above questions and the answer for all the above questions is YES, then you are on the right track.
Below is the mind map containing best practices for writing a perfect feature file:
Want to know more about best practices, principles, frameworks and reusable assets? Get in touch with us by filling the below form.