MockMaker Logo

Download MockMaker

This page describes how to download and use the latest version of MockMaker which has both a command line interface and a standalone GUI.

MockMaker has been tried on Windows 2000, Linux, Java 1.2 & Java 1.4


1. Download here:

2. Unzip the file

3. Java (Sun's JDK1.2/1.3/1.4) must already be installed, with java on the path

4. Add MockMaker and mockmaker.cfg to the classpath; e.g. 'set classpath=%classpath%;INSTALL_DIR\lib\mockmaker.jar;INSTALL_DIR\lib\mmmockobjects.jar;INSTALL_DIR'

5. To ensure everything is ok, you can run the test suite. (You will need junit on classpath) Execute 'java mockmaker.tests.AllTests', and the JUnit tests for MockMaker should run with no errors (you will also need JUnit on the classpath).


Command Line

To run MockMaker, execute 'java mockmaker.MockMaker INTERFACE_NAME' where INTERFACE_NAME is the name of the java interface for which you want to create a mock object class. MockMaker will then write the source code for the mock object class onto standard output. In order to write to a file, execute 'java mockmaker.MockMaker INTERFACE_NAME > FILE_NAME'.

Stand alone GUI

To run the MockMaker GUI, execute 'java org.subconscious.mockmaker.gui.MockMakerGUI'. This launches a GUI from where you can chose the INTERFACE .class file and the Mock implementation source file.


You can change the naming of methods that MockMaker produces, by editing the file "mockmaker.cfg" as appropriate, and making sure it is on the classpath. An example file "old.cfg" gives the naming conventions that version 1.01 of mockmaker used; to use these conventions, delete the file "mockmaker.cfg" and rename "old.cfg" to "mockmaker.cfg" and make sure it is on the classpath.


Execute 'java mockmaker.MockMaker mockmaker.tests.AcceptableInterface' and you should get the some java source code printed on standard output. Save this source code as "".

Alternatively, launch the GUI, and select the .class file "INSTALL_DIR\mockmaker\tests\AcceptableInterface" select directory "INSTALL_DIR" and type "" as the source file name and press the 'Make' button. Compile this source file - note that to compile this source file, you will have to edit it to include an import statement "import mockmaker.tests.*;".

MockAcceptableInterface is a "mock" implementation of the interface AcceptableInterface. An instance of MockAcceptableInterface can be used to test objects that use AcceptableInterface objects. For example, using an instance of AcceptableInterface called "foo":

* to test that method "minimalMethod" of foo is called twice, use "foo.setExpectedMinimalMethodCalls(2)" and "foo.verify()" to test that those calls happened

* to test that method "normalMethod" of foo is called with parameters "new Integer(4)" then "new Integer(2)", use "foo.addExpectedNormalMethodValues(new Integer(4)); foo.addExpectedNormalMethodValues(new Integer(2)); " and "foo.verify();" to test that those calls happened (Note that return values will also have to be set as in the example below, otherwise foo won't know what values to return when normalMethod is called)

* to set up method "normalMethod" to return "Hello" the first time it is called and "World" the second time it is called, use "foo.setupNormalMethod("Hello"); foo.setupNormalMethod("World");"

* NOTE that the line "keepUsingLastReturnValue=false" in the file "mockmaker.cfg" can be modified to "keepUsingLastReturnValue=true" in order to make the MockObjects created by MockMaker continue using the last value set by the appropriate "setup" method rather than running out of return values if enough values have not been set. This allows the "setup" methods the equivalent behaviour of previous versions of MockMaker where a single return value was set and always returned.

To learn more about MockObjects, see the MockObjects web site.

Other MockMaker related Files

Older versions of any of the packages are here if you need them: Sourceforge Files

MockMaker uses parts of the Mock Objects project. The neccessary files are included in Mockmaker - no additional download is needed.