Behavior-driven Development
Writing a test that clearly states its intent, is useful in itself. However, as we get into the habit of making ourselves clearly understood, we start to notice a pattern. Behavior-driven Development (BDD) encourages us to step back and think of how the application should behave end-to-end first, and only then concentrate on the smaller details. After all, our application can be refactored many times with all of the IDs and names changing while still maintaining the same intended behavior.
Advantages of BDD
By separating the implementation details from the behavior definition, our tests gain a lot of advantages:
Better test understanding: If the test is written properly, then it is possible to know exactly what the test plans to do without being confused by code details.
Modular implementation: The methods that perform the actual implementation can be shared while testing.
Note
For more information on code reuse, see the The DRY testing pattern section in Chapter...