The jMock Cookbook

How to...

  1. Get Started1
  2. Create Mock Objects, States & Sequences with Less Boilerplate2
  3. Define Expectations3
  4. Return Values from Mocked Methods4
  5. Throw Exceptions from Mocked Methods5
  6. Match Parameter Values6
  7. Precisely Specify Expected Parameter Values7
  8. Expect Methods More (or Less) than Once8
  9. Expect a Sequence of Invocations9
  10. Expect an Invocation Between Two Other Invocations10
  11. Ignore Irrelevant Mock Objects11
  12. Override Expectations Defined in the Test Set-Up12
  13. Match Objects and Methods13
  14. Write New Matchers14
  15. Write New Actions15
  16. Easily Define Actions with Scripts16
  17. Test multithreaded code:17

    1. Unit test an object that executes concurrent tasks18
    2. Unit test an object that schedules tasks19
    3. Use JMock with multithreaded code20
    4. Synchronise with threads started by the code under test21
    5. Stress-test synchronisation code22
  18. Mock Generic Types23
  19. Mock Abstract and Concrete Classes24
  20. Use jMock with Languages Other Than Java25
  21. Upgrade from jMock 1 to jMock 226
  22. Use jMock in Maven Builds27
  23. Understand method dispatch in jMock 228
  24. Mock Classes in Eclipse Plug-in Tests29
  25. Mock asynchronous GWT services30

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

Links:

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

2. Create Mock Objects, States & Sequences with Less Boilerplate: http://www.jmock.org/auto.html

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

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

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

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

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

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

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

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

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

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

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

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

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

16. Easily Define Actions with Scripts: http://www.jmock.org/scripting.html

17. Test multithreaded code:: http://www.jmock.org/threads.html

18. Unit test an object that executes concurrent tasks: http://www.jmock.org/threading-executor.html

19. Unit test an object that schedules tasks: http://www.jmock.org/threading-scheduler.html

20. Use JMock with multithreaded code: http://www.jmock.org/threading-synchroniser.html

21. Synchronise with threads started by the code under test: http://www.jmock.org/threading-waiting.html

22. Stress-test synchronisation code: http://www.jmock.org/threading-blitzer.html

23. Mock Generic Types: http://www.jmock.org/mocking-generic-types.html

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

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

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

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

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

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

30. Mock asynchronous GWT services: http://www.jmock.org/gwt.html

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