Java various mock tools comparison

Source: Internet
Author: User

Turn from:

http://billben.iteye.com/blog/1872196

http://harrywu304.blog.163.com/blog/static/8456603201141611147777/


Available Mock toolkit There are many, more common there are easymock, Jmock and Jmockit, and so on, in the end to choose which, jmockit the official network has a feature comparison list, very detailed:

Feature EasyMock Jmock Mockito Unitils Mock Powermock:
EasyMock
Api
Powermock:
Mockito
Api
Jmock
It
Invocation count constraints
Recording strict expectations


Explicit Verification


Partial mocking
No method call to switch from record to replay


No Extra code for implicit verification

N/A N/A
N/A
No Extra "Prepare for test" code

No need to use @RunWith annotation or base
Test class



Consistent syntax between void and Non-void methods



Argument matchers for some parameters only,
Not all





Easier argument matching based on properties
of Value objects

Cascading mocks


Support for mocking multiple interfaces



Support for mocking annotation types

Partially ordered expectations




Mocking of constructors and Final/static/native/private methods



Declarative application of Mocks/stubs to
Whole test Classes




Auto-injection of mocks


Mocking of "new-ed" objects



Support for mocking enum types



Declarative mocks for the test class (mock
Fields


Declarative mocks for test methods
(Parameters, local fields)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.