log
クラス: matlab.unittest.TestCase
パッケージ: matlab.unittest
テスト実行中の診断情報の記録
構文
log(testCase,diagnostic)
log(testCase,v,diagnostic)
説明
log(
は指定した診断情報を記録します。log メソッドは、実行中にテストの情報を記録する手段を提供します。テスト フレームワークでは、testCase
,diagnostic
)matlab.unittest.plugins.LoggingPlugin
などの適切なプラグインを追加してテスト フレームワークの動作を構成した場合に限り、記録したメッセージが表示されます。
log(
は指定した詳細レベル testCase
,v
,diagnostic
)v
で診断情報を記録します。
入力引数
testCase
— テスト ケースのインスタンス
matlab.unittest.TestCase
インスタンス
テスト ケースのインスタンス。matlab.unittest.TestCase
として指定します。
diagnostic
— 失敗時に表示する診断情報
文字配列 | string 配列 | 関数ハンドル | matlab.automation.diagnostics.Diagnostic
インスタンス
失敗時に表示する診断情報。string 配列、文字配列、関数ハンドルまたは matlab.automation.diagnostics.Diagnostic
インスタンスとして指定します。
v
— 詳細レベル
2
(既定値) | 1
| 3
| 4
| matlab.automation.Verbosity
列挙 | string または char ベクトルとしての列挙名
詳細レベル。1 ~ 4 の整数値、matlab.automation.Verbosity
列挙オブジェクト、事前定義された列挙メンバー名のいずれかに対応する string スカラーまたは文字ベクトルとして指定します。診断メッセージの既定の詳細レベルは Concise
です。整数値は matlab.automation.Verbosity
列挙のメンバーに対応します。
数値表現 | 列挙型メンバー名 | 詳細レベルの説明 |
---|---|---|
1 | Terse | 最小限の情報 |
2 | Concise | 中程度の情報量 |
3 | Detailed | ある程度の補足的な情報 |
4 | Verbose | 多くの補足的な情報 |
例
診断情報の記録
作業フォルダーのファイル sampleLogTest.m
に、関数ベースのテストを作成します。
function tests = sampleLogTest tests = functiontests(localfunctions); function svdTest(testCase) import matlab.automation.Verbosity log(testCase,'Generating matrix.') m = rand(1000); log(testCase,1,'About to call SVD.') [U,S,V] = svd(m); log(testCase,Verbosity.Terse,'SVD finished.') verifyEqual(testCase,U*S*V',m,'AbsTol',1e-6)
コマンド プロンプトで、テストを実行します。
results = run(sampleLogTest);
Running sampleLogTest [Terse] Diagnostic logged (2022-10-15 18:35:02): About to call SVD. [Terse] Diagnostic logged (2022-10-15 18:35:20): SVD finished. . Done sampleLogTest __________
既定のランナーはレベル 1 (Terse
) の診断情報を報告します。
レベル 1 および 2 の診断情報を報告するテスト ランナーを作成し、テストを再度実行します。
import matlab.unittest.TestRunner import matlab.unittest.plugins.LoggingPlugin runner = TestRunner.withNoPlugins; p = LoggingPlugin.withVerbosity(2); runner.addPlugin(p) results = runner.run(sampleLogTest);
[Concise] Diagnostic logged (2022-10-15T18:36:05): Generating matrix. [Terse] Diagnostic logged (2022-10-15T18:36:05): About to call SVD. [Terse] Diagnostic logged (2022-10-15T18:36:05): SVD finished.
バージョン履歴
R2014b で導入
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)