There are typically ways of writing tests. Anyone new to testing might want to read Writing testable code.
Test Driven Development, TDD
You write tests before implementing the functional code. For those who haven’t tried it, it sounds horrible. For those who have, they will know it delivers the best quality. It’s a mindset thing and really doesn’t take any longer.
DevMate is a huge help for TDD. DevMate makes Black Box Testing a breeze and if you are following TDD, then you are, almost by definition, using Black Box Testing. In fact, because DevMate promotes the involvement and shared responsibility of Domain Experts, POs and QA Engineers, developers will end up spending far less time writing tests and can concentrate on functional code.
The most common approach is to write the functional code first and only then think about tests. It works perfectly well for experienced developers who know the requirements intimately. But how often is that really the case?
If you do follow the Code First approach, then DevMate is still as much of help and time saver.
Most developers have to deal with Legacy Code. There’s Legacy Code and then there’s Legacy Code of course.
Older legacy code was probably written without any consideration for unit testing and will be tightly coupled.
In this case you have four choices.
Pray hard that it never breaks and do something else.
Refactor the really critical parts to make it properly testable.
Set up some integration tests as best you can.
A combination of the above (and a prayer is always helpful with legacy codebases)