Using Test Doubles With Mockito
Good unit testing comes from testing the System Under Test (SUT) in isolation of the components it depends on to allow us to focus only on the behavior of our component and not have to worry about the added complexity of the other moving parts outside of it's bounds. However, the way that the
SUT interacts with its collaborators is very important… we want to be able to specify these interactions as part of its behavior without violating encapsulation by either providing indirect inputs to the system or by verifying the indirect outputs.
Test Doubles allow us to specify examples for the SUT's collaboration with dependent components by allowing us to stub dependencies to return canned results, or record interactions with a dependency to verify the indirect output from the SUT.
A number of ways of using Test Doubles exist, whether hand rolling your own hard coded Test Doubles or using one of many popular frameworks. In this session, I will cover using Mockito to elegantly and expressively use all types of Test Doubles to aid in testing your objects in isolation as well as comparing how Mockito stacks up against other popular frameworks such as Jmock and EasyMock.
About James Carr
James is a contractor in the St.Louis area that shares a passion for software craftsmanship and has enjoyed software development since he wrote his first program in Basic on the Tandy Color Computer 3 way back in 1988.
In addition to a passion for technology, he also has a keen interest in improving teamwork and collaboration through interactive activities to get people thinking creatively and develop stronger, richer communication channels with their stakeholders.
More About James »