In this chapter, we will cover the following recipes:
In this chapter, we will take a look at other mocking frameworks that are quite well known in the Java world. The idea of this chapter is not to state whether one mocking framework is better than Mockito, but to point out differences in both their syntax and approach.
Remember that the examples presented in this chapter are very simple and do not show all of the possible ways of using the mocking frameworks, since you could write books about any of them.
Before moving forward, it's worth mentioning the difference between a strict mock and a non-strict one:
It's important to understand the difference because EasyMock, JMockit, and JMock allow you to create either of those mocks.
Let's come back to the chapter's structure. We will start off by taking a look at EasyMock, which is Mockito's predecessor (in fact, Mockito began as the EasyMock's fork). Next, we will take a look at JMockit and JMock, which are similar to some extent. Finally, we will see how you can do things the Groovy way using Spock.
In all cases, we will use the tax transferring system which will throw an exception during the transfer of tax.
18.221.254.61