Trade-offs in Unit Testing – Part II Stubs

After spending a couple days implementing test cases using Mock objects, I switched to testing using stubs, because I still needed to verify the functionality of the code.

It took me only a few hours to write the test cases I needed using stubs, and with and IDE it’s even easier. But I don’t think its a fair assessment to compare using Mocks to Stubs because each tool is used for a different purpose (behavioral vs. functional).

However, I did notice one very obvious disadvantage to using stubs; if your application is dynamic and the functionality is changing test cases become brittle quickly, and require you to add additional members or functions.

But I would still advocate using stubs in writing test cases, because of the simplicity involved in writing them, being able to abstract away or limit dependent classes.

  1. No comments yet.

  1. No trackbacks yet.

Anti-Spam Protection by WP-SpamFree