Home Blog Trade-offs in Unit Testing – Part II Stubs

Trade-offs in Unit Testing – Part II Stubs

Poornima
Founder, Femgineer
· October 14, 2008 · 1 min read

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

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.

Enhanced by Zemanta
Pocket
Share on reddit
Share on LinkedIn
Bookmark this on Digg

← Presentation for Code Camp ‘08 All posts Presentation for Code Camp ‘08 →