Skip navigation.

Mock Objects

Java mocking without dependency injection

Mock Objects
Interesting article about using bytecode manipulation to mock dependencies.

Mocha - a new twist on mocking in Ruby

Mock Objects | ruby
Mocha is a library for mocking and stubbing within tests using a syntax like that of JMock and SchMock. The main difference between this mocking library and others like FlexMock and RSpec is that it allows you to mock and stub methods on real (non-mock) classes and instances.

Rhino.Mocks v. 2.0 Announced. Yes, it's a Mock Object Framework.

.NET | Mock Objects

Ayende has announced that he's released Rhino.Mocks v. 2.0: his own version of what he'd like in a Mock Object framework. I haven't yet got a chance to try it out, but it certainly sounds interesting!

"Rhino.Mocks is an attempt to create easier way to build and use mock objects and allow better refactoring support from the current tools. It's a hybrid approach between the pure Record/Replay of EasyMock.Net's model and NMock's expectation based model. Rhino.Mocks originated from EasyMock.Net and attempt to improve on their model to create easy to use and power mocking framework. It's free for use and modification for free and commercial software.

The Mock Objects elevator speech

Mock Objects
A friend asked me by email the other day :"So why do I need mock objects?" I came up with this in roughly 3 minutes so it's a bit rough, but it'll do to drive the point home, I hope. Note, that this does not really explain the *technical* side of it too much. Just the logic behind the concept.
 
Mock objects are there for when you need to replace or remove dependencies from code under test.
Let's say you have a class that manages user logins. Whenever a user login fails the class needs to report to a logger class, or maybe even an email class, or some remote web service to authenticate. If you want to write a test for the logic in the login class (an tests are just methods that call methods on the tested class, really) you want your test to run fast, and to run easily without too much fussing and configuration so that you can get fast feedback.

Schmock: Ruby mock library

Mock Objects | ruby
Simple mock object implementation knocked together while developing a Ruby on Rails app. Draws from the jmock stable of mocking.

Python Mock Library: mock objects for Python

Mock Objects | python
Mock object library for Python. This library enables the easy creation and use of Mock objects for Python unit testing. The Mock objects can contain expectations about how they are used, and can validate themselves against the class being mocked.

Rhino Mocks: .NET mocking framework

.NET | Mock Objects
A dynamic mock object framework for the .Net platform. Its purpose is to ease testing by allowing the developer to create mock implementations of custom objects and verify the interactions using unit testing.

Rhino.Mocks is an attempt to create easier way to build and use mock objects and allow better refactoring support from the current tools. It's a hybrid approach between the pure R

FlexMock: mock objects for Ruby

Mock Objects | ruby
FlexMock is a simple mock object for unit testing in Ruby. The interface is simple, but still provides a good bit of flexibility.