Behavior-driven development: Difference between revisions

Content deleted Content added
m Added links to lead section to help context.
Line 65:
 
* '''Test size''': each test (that is each test method) should not be longer than 15 lines of code (not counting empty lines). Test methods that are longer are either too complex (or the implementation is inefficient) or test too much behavior. Small tests are more expressive - it's easier to understand the behavior that is tested - and are easier to maintain and [[refactor]].
* '''Mock objects''': the usage of [[mock object|mock objects]] is encouraged (e.g. by using the [[EasyMock]] framework for Java) to achieve the previous goal. Mock frameworkframeworks create easy to use - and verify - objects that make tests more accurate, shorter and easier to maintain since the framework creates the implementation of the objects, not the developers that write the behavioral tests.
* '''Helper methods''': some behavior is best implemented in a helper method (e.g. load this or that from the database) that can be easily tested and called from elsewhere in the application. These methods help to make the code more expressive (through expressive method and argument names) and easier to test.
* '''No dependencies''': behavioral tests should not depend on other test cases, the execution order of tests or test cases or the presences of any configured system. This assures that only a limited, well-defined behavior in tested in a fine-grained manner. The opposite is to test fully configured application (components) in a coarse-grained matter. This aspect of these an application is important yet it is the ___domain of [[Integration tests]].