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. Easily Define Actions with Scripts15
  16. Test Multithreaded Code with Mock Objects16
  17. Mock Generic Types17
  18. Mock Abstract and Concrete Classes18
  19. Use jMock with Languages Other Than Java19
  20. Upgrade from jMock 1 to jMock 220
  21. Use jMock in Maven Builds21
  22. Understand method dispatch in jMock 222
  23. Mock Classes in Eclipse Plug-in Tests23
  24. Mock asynchronous GWT services24

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

Links:

1. Get Started: getting-started.html

2. Define Expectations: expectations.html

3. Return Values from Mocked Methods: returning.html

4. Throw Exceptions from Mocked Methods: throwing.html

5. Match Parameter Values: parameters.html

6. Precisely Specify Expected Parameter Values: matchers.html

7. Expect Methods More (or Less) than Once: cardinality.html

8. Expect a Sequence of Invocations: sequences.html

9. Expect an Invocation Between Two Other Invocations: states.html

10. Ignore Irrelevant Mock Objects: ignoring.html

11. Override Expectations Defined in the Test Set-Up: override.html

12. Match Objects and Methods: match-object-or-method.html

13. Write New Matchers: custom-matchers.html

14. Write New Actions: custom-actions.html

15. Easily Define Actions with Scripts: scripting.html

16. Test Multithreaded Code with Mock Objects: threads.html

17. Mock Generic Types: mocking-generic-types.html

18. Mock Abstract and Concrete Classes: mocking-classes.html

19. Use jMock with Languages Other Than Java: other-languages.html

20. Upgrade from jMock 1 to jMock 2: upgrade1to2.html

21. Use jMock in Maven Builds: maven.html

22. Understand method dispatch in jMock 2: dispatch.html

23. Mock Classes in Eclipse Plug-in Tests: eclipse.html

24. Mock asynchronous GWT services: gwt.html

25. jMock Users mailing list: mailing-lists.html