Write Your Test Code First – Part 1: Basics

Update: In the previous iteration of this post, the addFieldService was a function instead of an object, it has been fixed.

The Dirty Word of Development

Testing has widely become that thing in web development (and maybe the industry as a whole) that is heralded as important but hardly done. Perhaps a lot of people are and just aren’t talking about it–hopefully, that is the case.

Why should developers be writing tests? Because despite the fact that it seems like “a waste of time” or something developers “can’t be bothered with” as many voices have yelled over and over again, testing saves developers time in the long run.

This post will walk through an example and show how writing the unit tests first do a lot for the developer, including:

  • Cleaner code
  • Less errors
  • Smaller production code

Continue reading →