Chapter 27Value Patterns
Patterns in This Chapter
Literal Value
Also known as
Hard-Coded Value, Constant Value
How do we specify the values to be used in tests?
We use literal constants for object attributes and assertions.
BigDecimal expectedTotal = new BigDecimal("99.95");
The values we use for the attributes of objects in our test fixture and the expected outcome of our test are often related to one another in a way that is defined in the requirements. Getting these values—and, in particular, the relationship between the pre-conditions and the post-conditions—right is crucial because it drives the correct behavior into the SUT.
Literal Values are a popular way to ...
Get xUnit Test Patterns: Refactoring Test Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.