Behavioral testing verifies software from an end user’s perspective, focusing on whole-system functionality and whether it meets stated requirements and specifications. section 6.1.2 section 6.1.3
Behavioral testing differs from other testing approaches in its scope and expression:
- Unit testing isolates individual functions or methods; integration testing checks interactions between components; behavioral testing describes system behavior through user stories or scenarios. section 6.1.3
- Write scenarios in Given-When-Then form: establish preconditions, perform actions, and assert expected outcomes. section 6.1.3
- Use mock objects when dependencies are difficult to configure, lie outside the test’s scope, or must produce controlled errors and edge cases. section 6.1.3 section 6.7
Asset manager scenario
A BDD scenario starts with a running Asset Manager, an initialized in-memory repository, and a mocked location mediator. It creates two assets costing $2,000 each, then checks that all assets total $4,000. Step definitions construct the dependencies, create the assets, retrieve them, and perform the assertion.
