Test the untestable

Introduction to seams

Legacy code

Is difficult to

  • Read
  • Understand
  • Extend
  • Maintain
  • Test

Reading primer


To me legacy code is simply code without tests .


Code without tests is bad code. It doesn't matter how well written it is; ... With tests, we can change the behavior of our code quickly and verifiably. Without them we really don't know if our code is getting better or worse.

General set-up

Without tests

DO NOT

change the surface of a class


Create a test suite for it


How without changing the surface?

Taming the beast

unusual test organization

  • side by side
  • inner classes




Demo

Taming the beast

static is evil

  • implicit dependency
  • difficult to test



delegate to the rescue

Demo

Taming the beast

delegate is out

  • very time consuming
  • calls have to change



interface seam

A seam is a place where you can alter behavior in your program without editing in that place .
Michael C. Feather

Demo

Questions?







Contact

E-Mail >  max@malook.de

Twitter >  @max_malook

G plus >  +Max Malook

Test the untestable

By Max Malook

Test the untestable

Introduction to seams

  • 1,232