maple_shaft
maple_shaft

Reputation: 10463

Java Mock Framework that supports Actual Results, and Static Methods

This question may have been asked before but I have very specific things that I am looking for. I would like to integrate unit testing into a legacy web application but to do this and make sure that my unit tests are truly repeatable and decoupled from data access code I need a good Mock Framework that supports the following conditions.

I would prefer to just use a single framework that has all of the following features although if no such framework exists then so be it. My frustration stems not from lack of choices but from too many it seems.

  1. Mock Instance methods
  2. Mock Static methods
  3. Mock return value of method
  4. Mock exception thrown
  5. Order of mocked method calls (Nice to have)
  6. Expected results vs. Actual Results (Nice to have)

Does anybody have any suggestions for Java mock frameworks that fit this criteria?

Upvotes: 3

Views: 324

Answers (2)

Aparna
Aparna

Reputation: 73

PowerMock framework can be used for doing the above features.

Upvotes: 0

Mario
Mario

Reputation: 51

Try jmockit. In my opinion it currently supports the most features compared to others. Also it's an active project, and you'll probably get some very fast responses on their user group.

Upvotes: 1

Related Questions