Comments about unit Testing
Project Manager’s dilemma Some project managers find the programmers are resistant to unit tests. Even it has been widely adopt by industry Some programmers assume there is a QA team to find the bug They don’t like spending time writing and running unit tests that won’t deliver in the build. It feels like a waste of time.
But The opposite is true !
True facts Most programmers who adopt unit testing actually find that it actually reduces the total time it takes to build software. It may take time to write the tests up front. But it costs more time to go back later and fixes all of the bugs that the unit tests would have caught.
How Unit Testing Improve programmers? 1. By improving the object interfaces or function definitions that the programmer use Simply put 早點使用, 儘早發現問題, 不要將介面 的使用與測試延遲到系統整合時期
A Common trap that plagues object-oriented design There’s no way to know how easy it is to use an object until code is built that uses it, but there is no way to build that code until the object is done. ( 非常令人深省的一段文字 ) In practice, test driven development is an effective way to avoid the trap.
How test driven development is run in practice Build a series of simple unit tests before object is built If an object is needed, build a mock objects to simulate it. Object interface is elaborated and work out first. Potential problems are avoided. Object is built later.
Test Cases Test cases may help programmer A to understand an object written by programmer B. They describe how the object is used.