Mocking and faking are ways to isolate code or components to ensure that unit tests run against the testable unit of code only without actually utilizing other components or dependencies of an application. Mocking differs from faking in that a mock can be inspected to assert the results of a test.

learn more… | top users | synonyms (1)

11
votes
3answers
3k views

What are the key factors in choosing a Mocking Framework?

I'm looking to get started with objects in my unit tests. It seems there are tons of good mocking frameworks out there. Do the different frameworks have different target audiences? What factors ...
15
votes
5answers
836 views

How are mock objects commonly misused?

I read an article recently which said that mock objects are often misunderstood and misused. Are there any clear mocking anti-patterns which I can look out for?
7
votes
3answers
368 views

Unit Testing: Should we care about distinguishing between Mocks and Stubs?

There's been a lot of talk in various blogs, forums and on StackExchange about the distinction between Mock and Stub objects (most of them specifically referencing the Rhino Mocks framework). These ...
41
votes
10answers
5k views

(Why) is it important that a unit test not test dependencies?

I understand the value of automated testing and use it wherever the problem is well-specified enough that I can come up with good test cases. I've noticed, though, that some people here and on ...
2
votes
1answer
87 views

Library to fake intermittent failures according to tester-defined policy?

I'm looking for a library that I can use to help mock a program component that works only intermittently - usually, it works fine, but sometimes it fails. For example, suppose I need to read data ...
10
votes
4answers
854 views

When should I use mock objects?

I've read a lot of things about TDD but I still have doubts. For example, I have these class diagrams: It's a simple example, just to learn about TDD and mock objects. Which test should I write ...
39
votes
8answers
15k views

Is static universally “evil” for unit testing and if so why does resharper recommend it?

I have found that there are only 3 ways to unit test (mock/stub) dependencies that are static in C#.NET: Moles TypeMock JustMock Given that two of these are not free and one has not hit release ...