Surrogate Framework

Surrogate is a complimentary unit testing framework, especially suitable for unit testing of large, complex Java systems. The framework integrates seamlessly with JUnit,MockEJB and various mock object implementations and is based on the AspectJ technology.

If you are tired of broken unit tests because of time-dependence, external dependencies or low quality on the tests, Surrogate might provide the answer.

The predecessor of Surrogate was used to introduce repeatable and isolated unit tests in a very large J2EE project. The project now has nearly 4000 unit tests running continously.

Features

Surrogate provides the following features:

  • Mocking of interfaces, classes and individual methods that normally are "impossible" to mock. You can easily mock a call to the System.currentTimeMillis method or replace an object new() assignment by a mock implementation. This allows you to achieve ~100 % code coverage on virtually all classes in your project.
  • Surrogate does not require that you refactor any of your production classes to achieve complete unit testing. You don't need converting to "inversion of control" or "micro containers" in order to create robust unit tests.
  • The complexity of the Surrogate framework is well hidden behind a small java API. This means that, in a project-team environment, most members do not need to learn any AOP basics, only the small API.
  • Used in combination with e.g. the MockEJB framwork, Surrogate can significantly improve the code-compile-test cycle for J2EE projects since you will not need to start the server or hot-deploying to run the unit tests.
  • Surrogate suports the Maven, Ant and Eclipsedevelopment environments.

Surrogate and Mock objects

Surrogate does not force you to use a certain type of mock objects. You might code your own objects from scratch, or use e.g. the EasyMock framework.

Using Surrogate

To start using the Surrogate framework, see the Getting Started guide.