↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

TripService kata

Kata for a legacy code hands-on session. The goal is to test the legacy TripService class, reach 100% coverage, and then refactor the code so both tests and production code clearly express the business rules.

The exercise describes a social networking site for travellers. Users must be logged in to see content, must be friends to see another user’s trips, and the code throws an exception when the user is not logged in. Unit tests for TripService must avoid the real UserSession and TripDAO because they depend on resources such as HTTP session and database.

Reading notes
#

  • Write tests for TripService until coverage reaches 100%
  • Refactor only after the class is covered by tests
  • Keep the public interface of TripService unchanged
  • Do not introduce state in TripService
  • The final code should make the business rules explicit
  • Unit tests should not call the real UserSession or TripDAO
  • The exercise focuses on TripService itself, not on external resources