The jMock Cookbook

How to...

  1. Get Started1
  2. Define Expectations2
  3. Return Values from Mocked Methods3
  4. Throw Exceptions from Mocked Methods4
  5. Match Parameter Values5
  6. Precisely Specify Expected Parameter Values6
  7. Expect Methods More (or Less) than Once7
  8. Expect a Sequence of Invocations8
  9. Expect an Invocation Between Two Other Invocations9
  10. Ignore Irrelevant Mock Objects10
  11. Override Expectations Defined in the Test Set-Up11
  12. Match Objects and Methods12
  13. Write New Matchers13
  14. Write New Actions14
  15. Test Multithreaded Code with Mock Objects15
  16. Mock Abstract and Concrete Classes16
  17. Use jMock with Languages Other Than Java17
  18. Upgrade from jMock 1 to jMock 218
  19. Use jMock in Maven Builds19
  20. Understand method dispatch in jMock 220
  21. Mock Classes in Eclipse Plug-in Tests21

To discuss or suggest entries in this Cookbook please join the jMock Users mailing list22.

Links:

1. Get Started: http://www.jmock.org/getting-started.html

2. Define Expectations: http://www.jmock.org/expectations.html

3. Return Values from Mocked Methods: http://www.jmock.org/returning.html

4. Throw Exceptions from Mocked Methods: http://www.jmock.org/throwing.html

5. Match Parameter Values: http://www.jmock.org/parameters.html

6. Precisely Specify Expected Parameter Values: http://www.jmock.org/matchers.html

7. Expect Methods More (or Less) than Once: http://www.jmock.org/cardinality.html

8. Expect a Sequence of Invocations: http://www.jmock.org/sequences.html

9. Expect an Invocation Between Two Other Invocations: http://www.jmock.org/states.html

10. Ignore Irrelevant Mock Objects: http://www.jmock.org/ignoring.html

11. Override Expectations Defined in the Test Set-Up: http://www.jmock.org/override.html

12. Match Objects and Methods: http://www.jmock.org/match-object-or-method.html

13. Write New Matchers: http://www.jmock.org/custom-matchers.html

14. Write New Actions: http://www.jmock.org/custom-actions.html

15. Test Multithreaded Code with Mock Objects: http://www.jmock.org/threads.html

16. Mock Abstract and Concrete Classes: http://www.jmock.org/mocking-classes.html

17. Use jMock with Languages Other Than Java: http://www.jmock.org/other-languages.html

18. Upgrade from jMock 1 to jMock 2: http://www.jmock.org/upgrade1to2.html

19. Use jMock in Maven Builds: http://www.jmock.org/maven.html

20. Understand method dispatch in jMock 2: http://www.jmock.org/dispatch.html

21. Mock Classes in Eclipse Plug-in Tests: http://www.jmock.org/eclipse.html

22. jMock Users mailing list: http://www.jmock.org/mailing-lists.html