Class: matlab.mock.MethodCallBehavior Package: matlab.mock
Specify mock object method call with only object as input
withExactInputs(behavior)
withExactInputs(behavior) specifies a mock object method call with only the object as an input.
behavior
expand all
matlab.mock.MethodCallBehavior
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
myMockBehavior.myMockedMethod
Create a mock with a myMethod method.
myMethod
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".
"hello"
testCase.assignOutputsWhen(withExactInputs(behavior.myMethod),"hello")
Call the method with only the object as an input.
output = myMethod(mock)
output = "hello"
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.
testCase.verifyCalled(withExactInputs(behavior.myMethod))
Verification passed.
withAnyInputs
You have a modified version of this example. Do you want to open this example with your edits?