matlab.unittest.plugins.DiagnosticsOutputPlugin クラス
名前空間: matlab.unittest.plugins
診断を出力ストリームに送るプラグイン
説明
DiagnosticsOutputPlugin
クラスは、診断を出力ストリームに送るプラグインを作成します。テスト フレームワークにより出力される診断のタイプと詳細レベルを設定するには、このプラグインを TestRunner
インスタンスに追加します。
構築
matlab.unittest.plugins.DiagnosticsOutputPlugin
は、失敗したイベントと Verbosity.Terse
レベルでログに記録されたイベントの診断を ToStandardOutput
ストリームに送るプラグインを作成します。
matlab.unittest.plugins.DiagnosticsOutputPlugin(
は、指定された出力ストリームに診断をリダイレクトします。たとえば、stream
)ToFile
を使用して作成されたストリームに、出力をリダイレクトできます。
matlab.unittest.plugins.DiagnosticsOutputPlugin(___,
は、1 つ以上の Name,Value
)Name,Value
のペア引数で指定された追加オプションを使用してプラグインを作成します。たとえば、DiagnosticsOutputPlugin('LoggingLevel',4,'IncludingPassingDiagnostics',true)
は、ログに記録されたすべてのレベルの診断を表示し、さらにパスした診断も表示するプラグインを作成します。
入力引数
stream
— 出力する場所
ToStandardOutput
(既定値) | matlab.automation.streams.OutputStream
のインスタンス
出力する場所。OutputStream
クラスのインスタンスとして指定します。プラグインは指定された場所に診断情報を送ります。既定では、プラグインは matlab.automation.streams.ToStandardOutput
ストリームを使用します。
例: matlab.automation.streams.ToFile('myFile.txt')
引数のオプションのペアを Name1=Value1,...,NameN=ValueN
として指定します。ここで Name
は引数名で、Value
は対応する値です。名前と値の引数は他の引数の後になければなりませんが、ペアの順序は重要ではありません。
R2021a より前では、コンマを使用してそれぞれの名前と値を区切り、Name
を引用符で囲みます。
例: DiagnosticsOutputPlugin('IncludingPassingDiagnostics',true,'OutputDetail',4)
は、パスした診断を含めて診断を最も詳細なレベルで表示するプラグインを作成します。
ExcludingFailureDiagnostics
— 失敗したイベントの診断を除外
false (既定値) | true
失敗したイベントの診断を除外するかどうか。false
または true
として指定します。既定では、プラグインは失敗したイベントの診断を含めます。
データ型: logical
IncludingPassingDiagnostics
— パスしたイベントの診断を含める
false
(既定値) | true
パスしたイベントの診断を含めるかどうか。false
または true
として指定します。既定で、プラグインはパスしたイベントの診断を含めません。
データ型: logical
LoggingLevel
— 診断ログの最大詳細レベル
1
(既定値) | 0
| 2
| 3
| 4
| matlab.automation.Verbosity
列挙オブジェクト | 列挙のテキスト表現
テスト レポートに含める診断ログの最大詳細レベル。0
から 4
までの整数スカラー、matlab.automation.Verbosity
列挙オブジェクト、または列挙のテキスト表現として指定します。プラグインは、指定されたレベル以下でログに記録された診断を含めます。
数値表現 | 列挙型メンバー名 | 詳細レベルの説明 |
---|---|---|
0 | None | 情報なし |
1 | Terse | 最小限の情報 |
2 | Concise | 中程度の情報量 |
3 | Detailed | ある程度の補足的な情報 |
4 | Verbose | 多くの補足的な情報 |
既定では、プラグインは matlab.automation.Verbosity.Terse
レベル (レベル 1) でログに記録された診断を含めます。診断ログを除外するには、LoggingLevel
を matlab.automation.Verbosity.None
(レベル 0) に指定します。
診断ログとは、log (TestCase)
メソッドおよび log (Fixture)
メソッドによってテスト フレームワークに送る診断です。
例: "LoggingLevel","detailed"
OutputDetail
— レポートするイベントの詳細レベル
3 (既定値) | 0 | 1 | 2 | 4 | matlab.automation.Verbosity
列挙 | string または char ベクトルとしての列挙名
レポートするイベントの詳細レベル。0 ~ 4 の整数値、matlab.automation.Verbosity
列挙オブジェクト、事前定義された列挙メンバー名のいずれかに対応する string スカラーまたは文字ベクトルとして指定します。整数値は matlab.automation.Verbosity
列挙のメンバーに対応します。
プラグインは、パスしたイベント、失敗したイベント、およびログに記録されたイベントを、OutputDetail
で指定された詳細レベルでレポートします。既定で、プラグインはイベントを matlab.automation.Verbosity.Detailed
レベル (レベル 3) で記録します。
数値表現 | 列挙型メンバー名 | 詳細レベルの説明 |
---|---|---|
0 | None | 情報なし |
1 | Terse | 最小限の情報 |
2 | Concise | 中程度の情報量 |
3 | Detailed | ある程度の補足的な情報 |
4 | Verbose | 多くの補足的な情報 |
プロパティ
ExcludeFailureDiagnostics
— 失敗したイベントの診断を除外するかどうかのインジケーター
false
(既定値) | true
この プロパティ は読み取り専用です。
失敗したイベントの診断を除外するかどうかのインジケーター。false
または true
(logical
0 または 1) として指定します。ExcludeFailureDiagnostics
の既定値は false
であり、失敗したイベントの診断が出力に含まれます。失敗したイベントの診断を出力から除外するには、プラグインの作成時に ExcludeFailureDiagnostics
を true
として指定します。
IncludePassingDiagnostics
— パスしたイベントの診断を含めるかどうかのインジケーター
false
(既定値) | true
この プロパティ は読み取り専用です。
パスしたイベントの診断を記録するかどうかのインジケーター。false
または true
(logical
0 または 1) として指定します。IncludePassingDiagnostics
の既定値は false
であり、パスしたイベントからの診断が出力から除外されます。パスしたイベントからの診断を出力に含めるには、プラグインの作成時に IncludePassingDiagnostics
を true
として指定します。
LoggingLevel
— プラグインが含める診断ログの最大詳細レベル
matlab.automation.Verbosity.Terse
(既定値) | matlab.automation.Verbosity
列挙オブジェクト
この プロパティ は読み取り専用です。
プラグインが含める診断ログの最大詳細レベル。matlab.automation.Verbosity
列挙オブジェクトとして返されます。このプラグインは、このレベル以下でログに記録された診断を含めます。このプロパティの既定値は matlab.automation.Verbosity.Terse
です。プラグインの作成時に異なるログ レベルを指定できます。
診断ログとは、log (TestCase)
メソッドまたは log (Fixture)
メソッドの呼び出しによってテスト フレームワークに送る診断です。
OutputDetail
— レポートするイベントの詳細レベル
Detailed
(既定値) | matlab.automation.Verbosity
インスタンス
この プロパティ は読み取り専用です。
レポートするイベントの詳細レベル。matlab.automation.Verbosity
列挙オブジェクトとして返されます。このプロパティの既定値は matlab.automation.Verbosity.Detailed
です。プラグインの作成時に、異なる出力詳細レベルを指定できます。
コピーのセマンティクス
ハンドル。コピー操作に対するハンドル クラスの影響については、オブジェクトのコピーを参照してください。
例
診断の表示をカスタマイズするプラグインを作成
以下のテスト クラスを含むファイル ExampleDiagOutputTest.m
を作成します。
classdef ExampleDiagOutputTest < matlab.unittest.TestCase methods(Test) function testOne(testCase) import matlab.automation.Verbosity testCase.log(Verbosity.Detailed,'Testing failing event') testCase.verifyEqual(42,13,'42 == 13') end function testTwo(testCase) testCase.log(3,'Testing passing event') testCase.verifyTrue(true,'true is true') end end end
ExampleDiagOutputTest
クラスからテスト スイートを作成します。プラグインなしでテスト ランナーを作成します。
import matlab.unittest.TestRunner import matlab.unittest.TestSuite import matlab.automation.Verbosity import matlab.unittest.plugins.DiagnosticsOutputPlugin suite = TestSuite.fromClass(?ExampleDiagOutputTest); runner = TestRunner.withNoPlugins();
既定の DiagnosticsOutputPlugin
を作成し、ランナーに追加して、テストを実行します。
plugin = DiagnosticsOutputPlugin; runner.addPlugin(plugin); result = runner.run(suite);
================================================================================ Verification failed in ExampleDiagOutputTest/testOne. ---------------- Test Diagnostic: ---------------- 42 == 13 --------------------- Framework Diagnostic: --------------------- verifyEqual failed. --> The numeric values are not equal using "isequaln". --> Failure table: Actual Expected Error RelativeError ______ ________ _____ ________________ 42 13 29 2.23076923076923 Actual Value: 42 Expected Value: 13 ------------------ Stack Information: ------------------ In C:\work\ExampleDiagOutputTest.m (ExampleDiagOutputTest.testOne) at 6 ================================================================================ Failure Summary: Name Failed Incomplete Reason(s) ============================================================================ ExampleDiagOutputTest/testOne X Failed by verification.
別のテスト ランナーを作成し、パスしたものも含めた Terse
レベルの診断を表示し、Detailed
レベル以下でログに記録された診断を表示する DiagnosticsOutputPlugin
を作成します。これをランナーに追加して、テストを再実行します。
runner = TestRunner.withNoPlugins(); plugin = DiagnosticsOutputPlugin('OutputDetail',Verbosity.Terse, ... 'LoggingLevel',3,'IncludingPassingDiagnostics',true); runner.addPlugin(plugin); result = runner.run(suite);
[Detailed] Diagnostic logged (2022-10-15 18:30:46): Testing failing event FAIL: ExampleDiagOutputTest/testOne in ExampleDiagOutputTest.testOne at 6 :: verifyEqual failed. [Detailed] Diagnostic logged (2022-10-15 18:30:47): Testing passing event PASS: ExampleDiagOutputTest/testTwo in ExampleDiagOutputTest.testTwo at 10 :: verifyTrue passed.
バージョン履歴
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)