%% Specify Method Call with Object Only
% 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".

testCase.assignOutputsWhen(withExactInputs(behavior.myMethod),"hello")

% Call the method with only the object as an input.

output = myMethod(mock)

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

output = mock.myMethod(123)

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

testCase.verifyCalled(withExactInputs(behavior.myMethod))

% Copyright 2012 The MathWorks, Inc.