Main Content


Class: matlab.mock.MethodCallBehavior
Namespace: matlab.mock

Specify mock object method call with only object as input


callBehavior = withExactInputs(behavior)


callBehavior = withExactInputs(behavior) returns a MethodCallBehavior object to define behavior when mock object method is called with only the object as an input.

Input Arguments

expand all

Behavior of the mock, specified as a matlab.mock.MethodCallBehavior instance. To create an instance of matlab.mock.MethodCallBehavior, call a method of the behavior object.

Example: myMockBehavior.myMockedMethod


expand all

Create a mock with a myMethod method.

testCase = matlab.mock.TestCase.forInteractiveUse;
[mock,behavior] = testCase.createMock('AddedMethods',{'myMethod'});

Set up behavior. If the method is called with only the object as input, return "hello".


Call the method with only the object as an input.

output = myMethod(mock)
output = 

Call the method with additional inputs. Since this behavior is not defined, the mock returns the default value.

output = mock.myMethod(123)
output =


Verify that the method was called at least once with only the object as an input.

Verification passed.

Version History

Introduced in R2017a