Summary

Mocking and spying techniques are used to isolate different parts of code or third-party libraries. They are essential if we are to proceed with great speed, not only while coding, but also while running tests. Tests without mocks are often too complex to write and can be so slow that, with time, TDD tends to become close to impossible. Slow tests mean that we won't be able to run all of them every time we write a new specification. That in itself leads to deterioration in the confidence we have in the our tests, since only a part of them is run.

Mocking is not only useful as a way to isolate external dependencies, but also as a way to isolate our own code from a unit we're working on.

In this chapter, we presented Mockito as, in our opinion, the framework with the best balance between functionality and ease of use. We invite you to investigate its documentation in more detail (http://mockito.org/), as well as other Java frameworks dedicated to mocking. EasyMock (http://easymock.org/), JMock (http://www.jmock.org/), and PowerMock (https://code.google.com/p/powermock/) are a few of the most popular.

In the next chapter we are going to put some functional programming concepts as well as some TDD concepts applied to them. For that matter, part of the Java functional API is going to be presented.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.11.247