Package: matlab.mock.actions
Define return values for method called or property accessed
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.
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.
repeat | Repeat defining return values |
then | Action for mock object interaction or action subsequent to defining return values |
Value. To learn how value classes affect copy operations, see Copying Objects.
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 the
Invoke
class.
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.
matlab.mock.actions.DoNothing
| matlab.mock.actions.Invoke
| matlab.mock.actions.ThrowException
| matlab.mock.TestCase
| when (MethodCallBehavior)
| when
(PropertyGetBehavior)