background preloader

Mocks Aren't Stubs

Mocks Aren't Stubs
The term 'Mock Objects' has become a popular one to describe special case objects that mimic real objects for testing. Most language environments now have frameworks that make it easy to create mock objects. What's often not realized, however, is that mock objects are but one form of special case test object, one that enables a different style of testing. In this article I'll explain how mock objects work, how they encourage testing based on behavior verification, and how the community around them uses them to develop a different style of testing. I first came across the term "mock object" a few years ago in the Extreme Programming (XP) community. Since then I've run into mock objects more and more. But as often as not I see mock objects described poorly. This difference is actually two separate differences. Regular Tests I'll begin by illustrating the two styles with a simple example. These two behaviors imply a couple of tests, these look like pretty conventional JUnit tests.

http://martinfowler.com/articles/mocksArentStubs.html

Related:  AgileTesting Frameworks

TDD : Introduction to Moq In this post, I provide an introduction to Moq which is the newest of the Mock Object Frameworks. Moq is promoted by its creators as easier to learn and use than other Mock Object Frameworks such as Rhino Mocks and TypeMock Isolator. Moq takes advantage of recent VB.NET and C# language features such as lambdas and generics. When creating mock objects with Moq, you use lambda expressions to represent the methods and properties that you want to mock. CookBook - googlemock - Google C++ Mocking Framework Cookbook - Google C++ Mocking Framework You can find recipes for using Google Mock here. If you haven't yet, please read the ForDummies document first to make sure you understand the basics. Note: Google Mock lives in the testing name space.

Master-Slave Pattern The Master-Slave pattern is often used for multi-threaded applications in which many instances of the same problem must be solved. (Travelling Salesman Problem, for example.) The master creates and launches slaves to solve these instances in "parallel". When all of the slaves have finished, the master harvests the results. Master-Slave pattern is also used for user interfaces and servers. In both cases the master listens for commands coming either from the user or from clients. Mocks and Stubs aren't Spies At this point, we all know the difference between mocks and stubs... right? Well, perhaps not. That's OK, I'll try to explain it. And if I do a poor job you can always go read the article. (I've tried to have these samples follow Fowler's samples so that the two articles can be read together easily). So in unit tests, when your system under test requires a collaborator you provide it with a dummy implementation that does nothing, like so.

New Version Of Rhino Mocks A dynamic mock object framework for the .Net platform. It's 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 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.

Introducing BDD « DanNorth.net History: This article first appeared in Better Software magazine in March 2006. It has been translated into Japanese by Yukei Wachi, Korean by HongJoo Lee, Italian by Arialdo Martini and French by Philippe Poumaroux and most recently into Spanish by Oscar Zárate, Turkish by Selim Öber and Russian. I had a problem. While using and teaching agile practices like test-driven development (TDD) on projects in different environments, I kept coming across the same confusion and misunderstandings.

V1_7_Primer - googletest - Getting started with Google C++ Testing Framework - Google C++ Testing Framework Google C++ Testing Framework helps you write better C++ tests. No matter whether you work on Linux, Windows, or a Mac, if you write C++ code, Google Test can help you. So what makes a good test, and how does Google C++ Testing Framework fit in? We believe: Inversion of Control Containers and the Dependency Injection pattern In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application. Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control". In this article I dig into how this pattern works, under the more specific name of "Dependency Injection", and contrast it with the Service Locator alternative. The choice between them is less important than the principle of separating configuration from use. One of the entertaining things about the enterprise Java world is the huge amount of activity in building alternatives to the mainstream J2EE technologies, much of it happening in open source.

Minimum Acceptable Code Coverage This paper discusses how to decide what percentage of code coverage you need. By Steve Cornett. Copyright © Bullseye Testing Technology 2006-2013. All rights reserved. Rhino Mocks « Niraj Bhatt – Architect's Blog I am no mockist. But I had to upgrade myself on this for one of my clients. Below are the few links I found useful. Hope they will help you as well. You can download Rhino Mocks here. Adapting to Inversion of Control and Dependency Injection You might have come across the phrases IoC, Dependency Injection, Mocking among others, these are commonly used when talking about “Inversion Of Control” which is the full meaning of the abbreviation IoC. So what is this “IoC” that everyone is talking about? Inversion of control is a principle in Software Engineering, let’s just take a look at the Wikipedia definition of this

List of unit testing frameworks This page is a list of tables of code-driven unit testing frameworks for various programming languages. Some but not all of these are based on xUnit. Columns (Classification)[edit]

Related:  db_test