http://www.infoq.com/news/2009/07/Better-Unit-Tests
- One Assert per test (where possible).
- If there are any "if else" inside a test, move the branches to individual test methods.
- Methods under test, if they, too, have if else branches, the method should be refactored.
- Name of the method should be the kind of test. For instance, TestMakeReservation is different from TestMakeNoReservation().
Charlie Poole, author of NUnit, rewords one Assert per to test to one “Logical Assert” – saying “Sometimes, due to a lack of expressiveness in the testing api, you need to write multiple physical asserts to achieve the desired result. Much of the development in the NUnit framework api has been out of an attempt to get a single assert to do more work.”
No comments:
Post a Comment