clearMockHistory
クラス: matlab.mock.TestCase
名前空間: matlab.mock
モック オブジェクトの相互作用の履歴をクリア
構文
clearMockHistory(testCase,mock)
説明
clearMockHistory(
は、記録されたモック オブジェクトの相互作用の履歴をクリアします。testCase
,mock
)clearMockHistory
メソッドでは、モック オブジェクトの動作はクリアされません。相互作用と動作の両方をクリアするには、新しいモックを作成します。
入力引数
testcase
— テスト ケースのインスタンス
matlab.mock.TestCase
オブジェクト
テスト ケースのインスタンス。matlab.mock.TestCase
オブジェクトとして指定します。
mock
— 履歴のクリア対象のモック
モック オブジェクト
相互作用の履歴がクリアされるモック。モック オブジェクトとして指定します。
例
モックの履歴のクリア
myMethod
メソッドを使用してモックを作成します。
testCase = matlab.mock.TestCase.forInteractiveUse; [mock, behavior] = testCase.createMock("AddedMethods","myMethod");
メソッドを呼び出してモックを操作します。その後、メソッドが呼び出されたことを検証します。
mock.myMethod('abc'); testCase.verifyCalled(behavior.myMethod('abc'))
Verification passed.
相互作用の履歴を表示します。
h = testCase.getMockHistory(mock)
h = SuccessfulMethodCall with properties: Name: "myMethod" Inputs: {[1×1 matlab.mock.classes.Mock] 'abc'} Outputs: {[]} Interaction summary: myMethod([1×1 matlab.mock.classes.Mock], 'abc')
記録された相互作用の履歴をクリアし、メソッドが呼び出されたかどうかを再テストします。今度は検証が失敗します。
testCase.clearMockHistory(mock)
testCase.verifyCalled(behavior.myMethod('abc'))
Verification failed. --------------------- Framework Diagnostic: --------------------- verifyCalled failed. --> Method 'myMethod' was never called. Specified method call: MethodCallBehavior [...] = myMethod(<Mock>, 'abc')
相互作用の履歴を再度表示します。空になっています。
h = testCase.getMockHistory(mock)
h = 1×0 InteractionHistory array with properties: Name
バージョン履歴
R2018b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)