O'Reilly logo

xUnit Test Patterns: Refactoring Test Code by Gerard Meszaros

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 27Value Patterns

Patterns in This Chapter

Literal Value 714

Derived Value 718

Generated Value 723

Dummy Object 728

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required