My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Links

Simple mock objects for java

CheesyMock is a small library for creating Java mock objects for use in your unit tests with a minimal amount of fuss.

For example, to quickly create a dummy HttpServletRequest, you only need to type

HttpServletRequest req = Cheesy.mock(HttpServletRequest.class);

or, to create an InputStream that always throws an exception when you try to close it (which I've actually found helpful when writing some tests):

InputStream is = Cheesy.mock(InputStream.class, new Object() {
   void close() {
      throw new IOException("bad luck, try again!");
   }
});

Documentation

For up-to-date documentation, please see the javadoc for the main class, Cheesy.java.

Requirements

CheesyMock requires Java 1.5. If you are running any previous version then seriously, what is wrong with you?

You need CGLib on your class path if you want to create mock objects of concrete classes, otherwise you are restricted to create mocks from interfaces. Other than that, CheesyMock has no external dependencies.

Versions

Version 1.1.4 Solves a couple of bugs related to method resolving.
Version 1.1.3 Minor bug
Version 1.1.2 Solves a bug with strict mocks. Adds WrappedDelegate functionality.
Version 1.1 A re-write from scratch to improve flexibility and generally make it easier for us to maintain and add new features. Has most of the capabilities of 1.0, but the API and most of the internals have changed.
Version 1.0 Kind of deprecated, and you really shouldn't use it. Unless you want to, I guess.

Powered by Google Project Hosting