The challenge for this week is to deal with seemingly redundant information, where the same scenarios are used for several different purposes.
How do I share scenarios between feature files?
There are a few situations when this kind of sharing is useful.
When doing platform migration projects, the old and the new system usually have almost the same functionality. For a period of time, both systems may need to be operational, so people usually want to test both of them. In cases such as these, the set-up and the contents of the scenarios are almost the same, with some minor variations, but the execution differs significantly because steps need to run against two different systems. A typical way to achieve this with Given-When-Then would be to use scenario outlines, where the example tables are the same, but the scenario bodies differ.
When two modules of a system have very similar (or identical) functionality, the scenarios describing those two functional areas will be very similar. For example, I worked on a banking platform where the client wanted to start trading with Canadian equities. The mental starting point for business users was to replicate the functionality for US equities, since the rules were sufficiently similar, and then start modifying them. In cases such as these, the set-up is different, and some minor scenarios will differ, but most of them will be the same.
When the business domain model and the technical model differ significantly, business users may want to prove test coverage by executing almost the same scenarios for different classes of inputs. In cases such as these, the set-up for the scenarios is different, but the rest is usually the same. For example, business users at a client of mine wanted executable specifications to show how foreign exchange contracts are executed for all the most important currency pairs. There were hundreds of scenarios across dozens of feature areas that would need to be executed and demonstrated to the business users for review. Apart from starting with different currencies, there was very little difference between them. The variations were mostly related to rounding as different currencies have different rounding rules. The underlying code was actually the same the scenarios always executed against the same service but because of business risk the client wanted to run tests for all the key currency pairs.
The problem in all such cases, and the reason why people want to share scenarios across feature files, is to reduce maintenance costs. When the scenarios are sufficiently similar, changing something in one group usually means that it needs to change in all the other groups as well. This becomes tedious and error-prone when the same data is copied in multiple places.
Your challenge for the next two weeks is to propose ways to reduce the maintenance overhead of working with duplicates, but still allow the same scenarios to run multiple times, with different set-up information, or different ways of executing the scenarios.
PS: … and don’t forget to share the challenge with your friends and team members by clicking on one of the social icons below 👇