During this semester my professor tried to convince us why is good to use unit tests during development, why is it good to validate data(Microsoft Application Block) and also he told us about using mocking(RhinoMocks) in order to test our methods when we didn't had access to a database.
I had to do some unit tests with mocking and in order to make them work i had to create by hand the objects hierarchy that was needed in order to test my method(It took me a while to write everything i needed).
The question that i want to put: in production is it useful to use mocking? Should i use it every time i have the chance? And also the effort made to write everything in order to test a method with mocks does it pay off?
thank you
Yes, using mock objects as one among your many unit testing tools is definitely a worthwhile endeavour.
However, it goes best with Test-Driven Development because the tests drive the design. When you begin to feel the pain of tightly coupled code because you have to maintain deeply nested structures, you know it's time to refactor to a more loosely coupled API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With