throwExceptionWhen
클래스: matlab.mock.TestCase
네임스페이스: matlab.mock
메서드 호출 또는 속성 상호 작용에 대한 예외 발생시키기
구문
throwExceptionWhen(testcase,behavior)
throwExceptionWhen(testcase,behavior,exception)
설명
입력 인수
예제
대안
throwExceptionWhen
메서드를 사용하는 것은 MethodCallBehavior
, PropertyGetBehavior
또는 PropertySetBehavior
클래스의 when
메서드와 함께 matlab.mock.actions.ThrowException
동작을 사용하는 것과 기능적으로 동일합니다. 예를 들어, 다음 코드 블록들은 기능적으로 동일합니다.
% Using the throwExceptionWhen method testCase.throwExceptionWhen(behavior.deposit(IsLessThan(0)), ... MException('Account:deposit:Negative', ... 'Deposit amount must be positive.')); % Using the ThrowException action with the when function import matlab.mock.actions.ThrowException when(behavior.deposit(IsLessThan(0)),ThrowException( ... MException('Account:deposit:Negative', ... 'Deposit amount must be positive.')))
ThrowException
동작을 사용하면 추가적인 기능을 사용할 수 있습니다. 예를 들어, 동일한 모의 객체 상호 작용에 대해 다른 후속 동작을 지정할 수 있습니다.버전 내역
R2017a에 개발됨