repeat
クラス: matlab.mock.actions.ThrowException
名前空間: matlab.mock.actions
例外のスローの繰り返し
構文
repeat(action,n)
説明
入力引数
例
ヒント
アクションを繰り返し、その後に
thenメソッドを呼び出さない場合、モックは引き続き繰り返しの値を返します。たとえば、次の銀行口座クラスのモックを考えてみます。import matlab.mock.actions.ThrowException testCase = matlab.mock.TestCase.forInteractiveUse; [mock, behavior] = testCase.createMock('AddedProperties',"IsJointAccount");
例外をスローするアクションを 2 回繰り返した場合、次のコードではフレームワークが引き続き例外をスローし、3 回目のプロパティ取得を実行します。
when(get(behavior.IsJointAccount),ThrowException().repeat(2)) tf = mock.IsJointAccount tf = mock.IsJointAccount tf = mock.IsJointAccount
一方、次のコードは例外を 2 回スローしてから、
falseを返します。import matlab.mock.actions.AssignOutputs when(get(behavior.IsJointAccount), ... ThrowException().repeat(2).then(AssignOutputs(false))) tf = mock.IsJointAccount tf = mock.IsJointAccount tf = mock.IsJointAccount
バージョン履歴
R2017a で導入