Content tagged with: mocking
When you need to perform unit testing in an independent way, you use mock objects. Mock objects are simulated objects that mimic the behavior of real objects in controlled ways. In this excerpt of their book “Pragmatic Unit Testing in C# with NUnit”, Andy Hunt, Dave Thomas and Matt Hargett explain how to avoid coupling when you build your C# unit tests.
It is rather rare to have access to the software testing techniques used by a large project to maintain the quality of its code base. In this blog post, Jan Wloka, a member of the team behind IBM’s Rational Team Concert, presents the different techniques and tools used to control software evolution and to improve the quality of their code base.
This extract from the book “Pragmatic Unit Testing in Java with JUnit” written by Andy Hunt and Dave Thomas provides an introduction to the usage of mock objects during Java unit tests. They define the usage of mocks in unit testing as the unit similar to the use of lighting doubles in the movies: A mock object is simply a debug replacement for a real-world
In this article, Brett Schuchert discusses how modern mocking tools affects positively our ability to work with legacy code and the possible negative implications of using mocking tools. These tools allow us to perform unit testing without actually changing the underlying code. He starts with a discussion about the challenges of unit testing and how mocking tools help to solve them; at least on the surface.
This article explains how Microsoft Fakes perform a similar role than mocking in unit testing, helping you to isolate the code you are testing in Visual Studio by replacing other parts of the application with stubs or shims. A stub replaces another class with a small substitute that implements the same interface. A shim modifies the compiled code of your application at run time so that instead of making a specified method call, it runs the shim code that your test provides.
This video presents Google Code convictions about creating tests for test-unfriendly code and the larger topic of testing. Project Hosting at Google Code is a large, well-established system written mostly in Python. When launched, Project Hosting’s testing consisted of the stock Subversion test suite and a handful of ad hoc smoke test scripts that required starting the entire system and manually inspecting the test’s output.
Mockito is an open source mock framework for Java that letsyou write beautiful tests with clean and simple API. This video shows how to verify mock objects using Mockito.
The testing strategy to adopt when you you run your code inside a Java EE container is the topic discussed in this blog post by Antonio Goncalves. To solve this issue, he presents a detailed step by step process to unit test an EJB with Mockito and how to do integration test with and without Arquillian with code samples. His conclusion is that since Java EE 6 it is now easy to use container and services in an embedded mode. Unit testing is good to test business code or code …
The Unit Testing and Mocking Tools Directory presents a list of unit testing and mocking tools, both open source and commercial, for the main programming languages (Java, .NET, ruby, etc). It contains also a list of resources associated to this topic. Visit http://www.unittestingtools.com/
Dealing with dependencies is the most challenging aspect of test-driven development (TDD). Mocks and stubs are created to isolate the behavior we would like to test. The article “The Art of Mocking” is a good introduction on this topic. Creating all these testing classes by hand can lead to troubles: sometimes developers duplicate these classes and other times the mocks and stubs become more complicated than the code.