Testing value objects

Testing value objects

How to test things like immutability

Fran Iglesias

November 02, 2018

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

9 slides
  1. Value Object (DDD) Small object Represents a concept Equality based

    on value Immutable: • Should be created consistent • Mutators should return new instances
  2. TDD VO Think of an invalid example Write a test

    that fails expecting exception Make the test pass Repeat as needed to test invalid cases
  3. TDD VO Think of a valid example Write a test

    that fails asserting value Make the test pass
  4. TDD VO Equality Write a test that fails expecting inequality

    Make the test pass Then write a test that fails expecting equality Make the test pass
  5. TDD VO Immutability Think of a valid example of a

    mutator Write a test that fails expecting a different instance Make the test pass

More Decks by Fran Iglesias

Other Decks in Programming