Main Content


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

Specify mock object method call with any number of inputs with any value


callBehavior = withAnyInputs(behavior)


callBehavior = withAnyInputs(behavior) returns a MethodCallBehavior object to define behavior when mock object method is called with any number of inputs that can have any value.

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 the behavior. Regardless of the inputs to the method, it returns "hello".


Call the method with various inputs.

output = mock.myMethod
output = 
output = mock.myMethod(123)
output = 
output = myMethod("abc",mock)
output = 

Verify that the method was called at least once with some set of inputs.

Verification passed.

Version History

Introduced in R2017a