The First guideline
Unit tests should be written first. This might seem odd or unintuitive at the beginning, but there are valid reasons for this choice.
Later means never
How many times have you heard, we’ll test it later? I have never seen a team finishing a project and releasing it to production and then allocating time to unit test their code.
Moreover, adding unit tests at the end will require code refactoring, which might break the product, and it is hard to justify to a non-technical person that a working system was broken because the team was adding unit tests. Actually, the statement we broke production because we were adding unit tests sounds ironic. Yes, you can refactor a working system while covered by other types of tests, such as Sintegration and acceptance tests, but it would be difficult to imagine that a team that didn’t have time to unit test previously had the time to build other tests that would fully cover the system.
Testing first ensures...