Preserving Encapsulation
Explore how to maintain encapsulation during test-driven development by focusing on testing behaviors through public methods. Learn to use value objects with custom equals and hashcode methods to verify private data without exposing it, ensuring clean and well-designed code.
We'll cover the following...
We'll cover the following...
Testing public methods
TDD is all about testing the behaviors of components, not their implementations. Having a test for the behavior we want enables us to choose any implementation that will do the job. We focus on what’s important—what a component does—not on the less important details—how it does it. Inside a test, this appears as calling public methods or functions on public classes and packages. The public methods are the behaviors we choose to expose to the wider application. Any ...