About Telerik JustMock

Fast, flexible, fully featured mocking framework.

Telerik JustMock is an easy to use mocking tool designed to help you create better unit tests, fast. JustMock makes it easier for you to create mock objects and set expectations independently of external dependencies like databases, web service calls, or proprietary code. The JustMock API is completely AAA (Arrange/Act/Assert) oriented thus helping you keep your unit tests well structured, clean and readable. No matter whether you try to mock an interface, a sealed class or a static class, the pattern you use is the same.

What Is Mocking and Why Do I Need It?

Mocking is a concept in unit testing where real objects are substituted with fake objects that imitate the behavior of the real ones. Mocking is done so that a test can focus on the code being tested and not on the behavior or state of external dependencies.

For example, if you have a data repository class that runs business logic and then saves information to a database, you want your unit test to focus on the business logic and not on the database. Mocking the “save” calls to your database ensures your tests run quickly and do not depend on the availability or state of your database. When you’re ready to make sure the “save” calls are working, then you’re moving on to integration testing. Unit tests should not cross system boundaries, but integration tests are allowed to cross boundaries and make sure everything works together (your code, your database, your web services, etc.).

What Can Be Mocked?

Mock objects can be created and maintained manually, but this is a time consuming and ultimately unproductive approach. Telerik JustMock allows you to focus on writing tests and forget about the mocking details. Mock objects are created automatically in memory when the tests run based on your simple configuration in the unit test. There are no “physical” mock objects that have to be maintained as your project changes.

JustMock allows you to mock everything from interfaces, virtual and abstract methods and properties to sealed classes, non-virtual methods and properties, static classes, methods and properties, even those from mscorlib like DateTime, File, FileInfo, etc. All these can be mocked without a single change of your production code.

Final and Static Mocking

Unlike other mocking frameworks, JustMock lets you mock:

  • Sealed classes: call methods of sealed classes even with internal constructors.
  • Static classes, methods, properties: create mocks of static classes, set expectations for static method and property calls, verify static method calls.
  • Final methods or properties: assert final methods, overloads, out and ref arguments.

Telerik JustMock Key Features:

  • Unit Testing Simplified
    Testing complex scenarios is now easier than ever.
  • Mocking MsCorLib Members/Functions
    Mock .NET framework members without additional set-up.
  • Intuitive API With Better Discoverability
    The intuitive API helps ensure a shorter learning curve.
  • Elevated Mocking
    Mock anything with JustMock.
  • As Simple as AAA
    The Arrange, Act, Assert pattern provides for well structured, clean and readable unit tests.
  • Fully Profiled Automocking
    Makes unit tests more stable.
  • Silverlight Elevated Mocking
    Easily mock everything in your Silverlight project.
  • Build Systems Integration
    JustMock works seamlessly in your continuous build configuration.
  • Integration with Visual Studio and Other Tools
    JustMock works with VS 2017, 2015 and 2013, and a number of other tools.