matlab.mock.actions.AssignOutputs Class
Namespace: matlab.mock.actions
Define return values for method called or property accessed
Description
To specify the values that the framework returns when a mock
object method is invoked or a mock object property is accessed, use
the AssignOutputs
class.
If you call a mocked method with fewer outputs than specified
by AssignOutputs
, the remaining outputs are discarded.
If you call a mocked method with more outputs than specified by AssignOutputs
, MATLAB® throws
an error.
Construction
action = AssignOutputs(
defines
the values for the mock object to return for a method call or property
access. The A1,...,An
)AssignOutputs
constructor accepts one or
more values, A1,...,An
, that correspond to the
values for the output arguments of the mock object method or the value
of the mock object property.
Input Arguments
Properties
Methods
repeat | Repeat defining return values |
then | Action for mock object interaction or action subsequent to defining return values |
Copy Semantics
Value. To learn how value classes affect copy operations, see Copying Objects.
Examples
Tips
The
AssignOutputs
action defines the value of the output at instance creation time. To specify that a mock object method invoke a function handle to determine output values when a mock object method is called, use theInvoke
class.
Alternatives
For simple definition of outputs, you can use the assignOutputsWhen
method of the matlab.mock.TestCase
class.
However, there is more functionality when you use the AssignOutputs
action.
Version History
Introduced in R2017a