Sundarrajk's Weblog

Mocking intricate dependencies

Posted on: April 17, 2012


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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Categories

Advertisements
%d bloggers like this: