Main Content

matlab.mock.MethodCallBehavior class

Package: matlab.mock

Specify mock object method behavior and qualify method calls

Description

Use the MethodCallBehavior object to specify behavior for a mock object method and to qualify method calls.

There are several ways to define behavior for a mock object method.

  • Pass a mock object action, such as matlab.mock.actions.AssignOutputs, to the when method of the MethodCallBehavior class.

  • Pass a MethodCallBehavior object to a method of the matlab.mock.TestCase class, such as assignOutputsWhen.

There are several ways to qualify interactions with the mock object method.

  • Pass a mock object constraint, such as matlab.mock.constraints.WasCalled, to the verifyThat, assertThat, fatalAssertThat, or assumeThat method of the matlab.unittest.TestCase.

  • Pass a MethodCallBehavior object to a method of the matlab.mock.TestCase class, such as verifyCalled or assumeNotCalled.

Construction

The mocking framework constructs a MethodCallBehavior instance when you call a method of the mock behavior object.

Methods

whenSpecify mock object method behavior
withAnyInputsSpecify mock object method call with any number of inputs with any value
withExactInputsSpecify mock object method call with only object as input
withNargoutSpecify mock object method call with defined number of output arguments

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects.

Introduced in R2017a