Progress Telerik JustMock

Partial Mocking

  • Partial mocking allows you to mock only specific members of an already created non-mock object while keeping the rest intact.
  • This feature is a part of the fastest, most flexible and complete mocking tool for crafting unit tests.
  • Our award-winning support team is dedicated to assisting you with any questions and issues you may have during your application development.
Mocking and Assert Functionality
Nasa, Visa, Microsoft Fox, Samsung, IBM World Bank Group, Volvo
  • Partial Mocking Overview

    Partial mocking allows you to mock only specific members of an object while keeping the rest intact. Thus, you can continue to work with your existing, original object, not a mock object, with the benefit of being able to test your code in isolation when needed.
    [TestMethod]
    public void ShouldMockInstanceCallPartially()
    {
        // Arrange
        Foo foo = new Foo();
        // Just a single method of the original object is mocked.
        Mock.Arrange(() => foo.Echo(Arg.IsAny<int>())).Returns((int arg) => arg);
      
        // Act
        int actual = foo.Echo(10);
      
        // Assert
        Assert.AreEqual(10, actual);
    }

    Partial mocking documentation
Background-NextSteps

Next Steps

See Plans & Pricing

Purchase individual products or any of the bundles

Download Free Trial

With dedicated technical support.