DCSIMG

 Subscribe in a reader

My opinion on mocking - Guy kolbis
Saturday, November 08, 2008 2:30 PM kolbis

My opinion on mocking

In my previous post I asked the question:

"Mock Framework, yes or no?"

I got some answers and now I would like to share with you my opinion.

I think that a mock framework can make the every day unit testing tasks easier. We all know that writing unit tests can be a demanding and exhausting work, right? Well mock objects will come in handy when we need to decouple objects and will surely save time and pain; however it also makes you (in some manner) stop thinking about the architecture / design of your code.

Let me explain my point. While mock framework helps you decouple tightly coupled components in an "artificial" way, it will make you ignore the need of that during the design and coding phase; thus you will end up writing "wrong" code that is still tightly coupled instead of decoupling them by design.

In my opinion there is an alternative. I think that using a "stub" framework can help you in both the every day tasks and the design. The stub framework will generate methods, classes and interfaces that will help you unit test your code. Microsoft has been working on that with Visual Studio and we can now use stub on several types. This surely helps me writing a "good" code in less time.

What do you think?

kick it on DotNetKicks.com תגים:

תוכן התגובה

# re: My opinion on mocking

Roy כתב/ה

What "Stub" framework has MS done? got any link?

Saturday, November 08, 2008 6:20 PM

# Mocking, Good Or Bad?

DotNetKicks.com כתב/ה

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Tuesday, November 18, 2008 4:15 AM

# re: My opinion on mocking

Chad Myers כתב/ה

> "We all know that writing unit tests can be a

> demanding and exhausting work"

This was my experience before TDD and following design principles like the SOLID principles, but not so much afterwards.

> "however it also makes you (in some manner)

> stop thinking about the architecture /

> design of your code."

I don't understand this statement. Why would mocking make you stop thinking about design?

Wednesday, November 26, 2008 10:12 AM

שלח תגובה

(שדה חובה) 
(שדה חובה) 
(אופציונלי)
(שדה חובה) 

Enter the numbers above: