Mocha is a library for mocking and stubbing within a TestCase using a syntax like that of JMock, and SchMock.
One of its main advantages is that it allows you to mock and stub methods on real (non-mock) classes and instances. You can for example stub ActiveRecord instance methods like create, save, destroy and even class methods like find to avoid hitting the database in unit tests.
Mocha provides a unified, simple and readable syntax for both traditional mocking and for mocking with non-mock objects.
EasyStub is a framework for making stubs. When you find most of time you are using a mock framework to create an object that always returns the same value, and you did not care about the interactions, what you need is actually a stub.
Examples:
to create stub:
MyInterface stub = createStub(MyInterface.class);
to return value:
make(stub.hello()).returning(‘hello’);
to throw exception:
make(stub.hello()).throwing(expectedException);
to throw exception for method without return value: