Consistency in Features
Writing good features is difficult. One way to write better features is to read them critically. Two criteria useful for this are consistency and exclusivity. So a feature should be consistent and exclusive, what does this mean.
For a feature to be consistent the following needs to apply
- The filename (including path) of the feature should be consistent with the title of the feature
Feature: Writing a blog
Feature: New article
The narrative should be consistent with the title
A scenario title should be consistent with the narrative
- A scenarios steps should be consistent with the scenario title
n.b. In addition each thing lower down the list should be consistent with all the things above it.
- Change of vocabulary: e.g. changing from talking about
articlesto talking about
- Introducing concepts outside the context. A classic in web applications is introducing different behaviour for different user types.
- Scenarios about separate content that appears on the same web page but has nothing to do with the feature.
This is partially covered by being consistent. What it is saying is that a feature should only contain scenarios that are part of its narrative. It might also be saying that these scenarios belong here and nowhere else. In practice having no overlap between features is probably impossible. However lots of overlap is probably a good indicator that things could be better
Reading your features critically and applying rules of consistency and exclusivity is useful in creating simpler features that have greater focus. This should be done before, during and after implementation. In the long run its far more important that your features make sense than go green. If they make sense but are red you will have lots of context to help create your fix. If they make no sense then when they go red (and they will some day) then finding a fix will be much harder.