Unit Test的三A原则: Arrange, Act, Assert
- Arrange any input data and processing classes needed for the test
- Perform the action under test
- Test the results with one or more asserts. Yes, it can be more than one assert, so long as they all work to test the action that was performed.
- Unit tests have one assert per test.
- Avoid if-statements in a unit test.
- Unit tests only “new()” the unit under test.
- Unit tests do not contain hard-coded values unless they have a specific meaning.
- Unit tests are stateless.
- It talks to the database
- It communicates across the network
- It touches the file system
- It can’t run at the same time as any of your other unit tests
- You have to do special things to your environment (such as editing config files) to run it.
目前在世界顶尖的软件咨询公司从事敏捷方法/极限编程、测试驱动开发、重构、面向对象设计、Java、C#和C++等方面的培训和项目指导。他是著名测试框架CppUnit和FitCpp的开发者，已经主持了三次面向对象界盛会OOPSLA上的CodeFest比赛。他还是《修改代码的艺术》（Working Effectively with Legacy Code）一书的作者。
Michael Feathers is the founder and Director of R7K Research & Conveyance, a company specializing in software and organization design. Michael is also the author of the book Working Effectively with Legacy Code (Prentice Hall, 2004).
- 在yc news上的讨论
- 在reddit上的讨论 8个板块都有讨论
- twitter上Michael Feathers的回复 引用了08年自己的一篇文章The Flawed Theory Behind Unit Testing
- Henrik Warne在个人博客上的response，跟Coplien在评论区又讨论了很多。
Uncle Bob and Jim Coplien’s debate on TDD提到更早之前(2008年2月)，Cope大老讨论Coplien and Martin Debate TDD, CDD and Professionalism另外一位Uncle Bob
comments powered by Disqus
Bob Martin is an Agile Manifesto author, and author of books on Agile Programming, XP, UML, O-O Programming, and C++. He is CEO and president of Object Mentor www.objectmentor.com/ Jim Coplien is a software pioneer in o-o programming and C++ and multi-paradigm design. He appreciates the human side of design, and has written critically acclaimed books on design and development.