Still Now I am using JUnit, I came across EasyMock, I am understanding both are for the same purpose. Is my understanding correct?
What are the advantages does EasyMock has over the Junit?
Which one is easier to configure?
Does EasyMock has any limitations?
Please help me to learn
When I explain unit testing I like to describe them as a list of phases:
jUnit is a Unit Testing Framework and provides all but the Expectations phase of testing. Alternatives in the Java space include:
Other Language equivalents include:
The concept of mocking is what added the new phase of Expectations, and since jUnit saw most of it's major development prior to the mocking movement, those features were not incorporated into the core, and a set of tools to fill that gap in the java space have opened up. Those libraries include
All of these libraries are compliments to any of the above Unit Testing frameworks I listed, including jUnit. They add the ability to define mock objects. Mock objects get "expectations" assigned to them, which are then asserted in the Assertions phase. Each Mock library accomplishes this slightly differently, but the major models are
I personally am a fan of the Expectations approach, which is more declarative, and less error prone, because it requires less methods to be called by the implementor, but that is a stylistic preference not a technical one.
Other Languages (since they came to the unit testing world later than java) don't have this seperation for the most part. The Unit Testing Library and Mock Library are one and the same. This is the case in phpunit, rspec. I imagine jUnit will not be incorporating this natively any time soon, since there is already such a rich set of alternative mock libraries available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With