Sundarrajk's Weblog

Archive for the ‘unit testing’ Category

How to use mock to simplify unit testing?

Not easy to test code dependent on other pieces like database.

Unit test only the smallest piece of code that does something useful should be unit tested.

Types of unit tests
1. Positive test
2. Negative test
3. Exception test
4. Performance test

Create multiple mocks instead of complex mock objects for different test cases.