Chapter 14. Separate View from Model

“To each his own. (Suum Cuique)”

Cicero

Tests can be made more maintainable by separating what appears to the user from the logic in the underlying business model.

Decouple the User Interface

For the CD Reservation story in the previous chapter, the business rule (the model) for determining whether a customer is allowed to reserve CDs was documented, and tests were written for it. This reservation tests go to some module inside the system, as shown in Figure 14.1. The triad did not talk about how the reservation-allowed condition is displayed (the view), and they did not make up tests for the user interface.

Figure 14.1. User Interface and Logic Tests

There are at least three ways that the application ...

Get Lean-Agile Acceptance Test-Driven Development: Better Software Through Collaboration now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.