background

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.
  • Part of the fastest, most flexible and complete mocking tool for crafting unit tests.
  • Our award-winning support team is available to assist you with any issues.
Mocking and Assert Functionality
  • 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
Next Steps