Package: matlab.mock.actions
Throw exception when method is called or when property is set or accessed
To specify that the framework throws an exception when a mock
object method is invoked or when a mock object property is set or
accessed, use the ThrowException
class. You can use
this action to inject error conditions into the system under test.
action = ThrowException
throws an exception
when a method is called or a property is set or accessed.
action = ThrowException(
specifies
the exception that the mock throws.exception
)
repeat | Repeat throwing exception |
then | Action for mock object interaction or action subsequent to throwing exception |
Value. To learn how value classes affect copy operations, see Copying Objects.
For simple definition of outputs, you can use the throwExceptionWhen
method of the matlab.mock.TestCase
class.
However, there is more functionality when you use the ThrowException
action.
matlab.mock.actions.DoNothing
| matlab.mock.TestCase
| when (MethodCallBehavior)
| when (PropertyGetBehavior)
| when (PropertySetBehavior)