Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing value objects

Testing value objects

How to test things like immutability

Fran Iglesias

November 02, 2018
Tweet

More Decks by Fran Iglesias

Other Decks in Programming

Transcript

  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