Legacy code

Chuck Greb
Android Testing
Published in
1 min readDec 19, 2016
Behind the Train Station…” by James Tworow licensed under CC BY-NC-ND 2.0

Working with legacy code can be challenging. Especially when it’s not tested.

If you find yourself in the unfortunate position of maintaining a legacy code base with insufficient (or nonexistent) test coverage there tends to be one simple question above all else.

Where do I start?

Fortunately there is also a simple answer.

Start where you are

  • If you are adding a new feature, write tests for that feature
  • If you are fixing a bug, write a failing test for the bug then make it pass
  • If you are refactoring a method, write some tests for that method (and maybe a few others around it)

Don’t just sit down and start writing a whole bunch of tests just for the sake of writing tests. Start small and iterate.

Using this approach you will wind up writing tests for the parts of your code that change most frequently first which is arguably where you need them the most.

--

--

Chuck Greb
Android Testing

Mission-driven engineering leader. Community organizer. Digital minimalist.