Preserving Encapsulation
Learn how to preserve encapsulation while testing public methods, avoiding common pitfalls, and ensuring code integrity.
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 private data or supporting code in classes, methods, or functions remains hidden.
Get hands-on with 1400+ tech skills courses.