RMock - a Java test-double framework

RMock 2.0.0 is a Java mock object framework to use with jUnit. RMock has support for a setup-modify-run-verify workflow when writing jUnit tests. It integrates better with IDE refactoring support and allows designing classes and interfaces in a true test-first fashion.

Getting started

Please, visit the "Documentation" link in the left navigation.

Current features

  • Enhances both interaction-based and state-based testing
  • Explicit error messages to shorten your feedback cycle
  • Test-double creation for interfaces and classes
  • Setup expectations on the actual method of the mocked object to support easy refactoring
  • Expectation modification regarding:
    • arguments
    • return value
    • exception throwing
    • perform any generic action
    • call multiplicity
  • An assertThat( actual, <constraint>) method that gives you more power than traditional jUnit's assertXxx(...), and more information when the assertion fails
  • A describable Expression/Constraint model supporting advanced asserts and error messages for expectations, objects and arrays.
  • A well defined workflow and clear test states
  • DynamicSuites that are flexibly configurable to include or exclude test classes depending on their runtime properties (no more include="**/Test*")
  • Nestable ordered and unordered sections for grouping and ordering expectations with clear error messages
  • Generate expectations for multiple methods with forEach(..) - if you, on a mock, want to setup expectations on all methods matching e.g. a specific name pattern, e.g. make sure that all get/set-methods on a mock are called, the forEach(..) setup can be used.
  • Documentation plugin (TDDoc). Document your test cases in your test cases. The RMock documentation is produced in that way (see "Documentation" in the left menu)
If you are looking for the mock framework for Ruby, please visit the Mockr homepage.

Planned features

  • JUnit 4 and Java 5 extensions

Future considerations

One of the reasons for making our own mock framework rather than building on one of the existing ones (like jMock or EasyMock) was our ideas of where we want to go with this framework. Some of the ideas and planned features are:
  • Thread testing support - adding thread-related constraints to rMock
  • Deployment testing plugin - define and abstract your deployment environments and manage them in a testfirst fashion and get the up-to-date and validated deployment diagrams at test-time.
  • Eclipse/IDE integration - get the information from rMock presented nicely in your IDE
  • AspectJ extension to enable testing more
  • Policy based testing - setup global rules for the code