Saturday, May 9, 2009

Guidelines for Unit Testing



1. Keep unit tests small and fast.

2. Unit tests should be fully automated and non-interactive

3. Make unit tests simple to run

4. Measure the tests

5. Fix failing tests immediately

6. Keep testing at unit level

7. Start off simple

8. Keep tests independent

9. Keep tests close to the class being tested

10. Name tests properly

11. Test public API
12. Think black-box

13. Think white-box

14. Test the trivial cases too

15. Focus on execution coverage first

16. Cover boundary cases
17. Provide a random generator

18. Test each feature once

19. Use explicit asserts

20. Provide negative tests

21. Design code with testing in mind

22. Prioritize testing
23. Prepare test code for failures

24. Write tests to reproduce bugs

25. Know the limitations

No comments:

Powered By Blogger

Followers