This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

matlab.mock.AnyArguments class

Package: matlab.mock

Match any number of arguments


Use the AnyArguments class to match any number of arguments when specifying mock behavior or qualifying mock interactions.


AnyArguments matches an unlimited, unspecified number of arguments, including zero. When defining mock behavior or qualifying mock interactions, specify AnyArguments as the last argument in the argument list.

Copy Semantics

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


collapse all

Match any number of arguments.

import matlab.mock.AnyArguments
import matlab.mock.actions.ThrowException

testCase = matlab.mock.TestCase.forInteractiveUse;

% Create a mock for a bank account class
[saboteurAccount,behavior] = testCase.createMock('AddedMethods',"deposit");

% Define behavior to throw exception with any input argument

% All of the following interactions throw an exception:


The AnyArguments class is functionally similar to using the withAnyInputs method of the matlab.mock.MethodCallBehavior class. For example, the following code blocks are similar.

% Using the AnyArguments class
import matlab.mock.AnyArguments;

% Using the withAnyInputs method
However, AnyArguments requires that the mock is the first input argument, and withAnyInputs does not. The MethodCallBehavior class provides additional methods to specify behavior and record interactions, such as specification of exact inputs or a number of outputs.

Introduced in R2017a