matlab.unittest.plugins.TAPPlugin.producingVersion13
クラス: matlab.unittest.plugins.TAPPlugin
名前空間: matlab.unittest.plugins
version 13 の TAP 形式の TAPPlugin
を作成する
構文
説明
matlab.unittest.plugins.TAPPlugin.producingVersion13
は、バージョン 13 の Test Anything Protocol (TAP) 形式の出力を生成するプラグインを作成します。TAP 形式バージョン 13 の出力では YAML ブロックにテスト診断情報が含まれています。既定では、プラグインは ToStandardOutput
ストリームを使用し、出力が画面に表示されます。この場合、画面に送られる他の出力によって TAP ストリームが無効になる可能性があります。
matlab.unittest.plugins.TAPPlugin.producingVersion13(
は、すべてのテキスト出力を指定された出力ストリームにリダイレクトします。たとえば、出力を stream
)ToFile
ストリームにリダイレクトできます。
matlab.unittest.plugins.TAPPlugin.producingVersion13(___,
は、1 つ以上の Name,Value
)Name,Value
のペア引数で指定された追加オプションをもつプラグインを作成します。
入力引数
stream
— プラグインがテキスト出力を送信する場所
matlab.automation.streams.ToStandardOutput
(既定値) | matlab.automation.streams.OutputStream
クラスのインスタンス
プラグインがテキスト出力を送信する場所。OutputStream
クラスのインスタンスとして指定します。既定では、プラグインは ToStandardOutput
ストリームを使用します。
例: stream = matlab.automation.streams.ToStandardOutput
例: stream = matlab.automation.streams.ToFile('myFile.tap')
名前と値の引数
引数のオプションのペアを Name1=Value1,...,NameN=ValueN
として指定します。ここで Name
は引数名で、Value
は対応する値です。名前と値の引数は他の引数の後になければなりませんが、ペアの順序は重要ではありません。
R2021a より前では、コンマを使用してそれぞれの名前と値を区切り、Name
を引用符で囲みます。
例: TAPPlugin.producingVersion13('LoggingLevel', Verbosity.Detailed)
は Detailed
以下のレベルでログに記録された診断を含めるプラグインを作成します。
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 | 多くの補足的な情報 |
例
TAP プラグインの作成
作業フォルダーの新規ファイルに、以下のテスト クラスを含む ExampleTest.m
を作成します。
classdef ExampleTest < matlab.unittest.TestCase methods(Test) function testOne(testCase) % Test fails testCase.verifyEqual(5,4,'Testing 5==4') end function testTwo(testCase) % Test passes testCase.verifyEqual(5,5,'Testing 5==5') end function testThree(testCase) % test code end end end
コマンド プロンプトで ExampleTest
クラスからテスト スイートを作成します。
import matlab.unittest.TestRunner import matlab.unittest.TestSuite import matlab.unittest.plugins.TAPPlugin import matlab.automation.streams.ToFile suite = TestSuite.fromClass(?ExampleTest);
既定のプラグインを使用して、出力をコマンド ウィンドウに表示するテスト ランナーを作成します。
runner = TestRunner.withTextOutput;
出力を MyTapOutput.tap
ファイルに送信する TAPPlugin
を作成します。
tapFile = 'MyTAPOutput.tap';
plugin = TAPPlugin.producingVersion13(ToFile(tapFile));
プラグインを TestRunner
に追加して、スイートを実行します。
runner.addPlugin(plugin) result = runner.run(suite);
Running ExampleTest ================================================================================ Verification failed in ExampleTest/testOne. ---------------- Test Diagnostic: ---------------- Testing 5==4 --------------------- Framework Diagnostic: --------------------- verifyEqual failed. --> The numeric values are not equal using "isequaln". --> Failure table: Actual Expected Error RelativeError ______ ________ _____ _____________ 5 4 1 0.25 Actual Value: 5 Expected Value: 4 ------------------ Stack Information: ------------------ In C:\work\ExampleTest.m (ExampleTest.testOne) at 4 ================================================================================ ... Done ExampleTest __________ Failure Summary: Name Failed Incomplete Reason(s) ================================================================== ExampleTest/testOne X Failed by verification.
プラグインによって作成されたファイルを表示します。
disp(fileread(tapFile))
TAP version 13 1..3 not ok 1 - ExampleTest/testOne --- Event: Event Name: 'VerificationFailed' Event Location: 'ExampleTest/testOne' Test Diagnostic: | Testing 5==4 Framework Diagnostic: | verifyEqual failed. --> The numeric values are not equal using "isequaln". --> Failure table: Actual Expected Error RelativeError ______ ________ _____ _____________ 5 4 1 0.25 Actual Value: 5 Expected Value: 4 Stack: | In C:\work\ExampleTest.m (ExampleTest.testOne) at 4 ... ok 2 - ExampleTest/testTwo ok 3 - ExampleTest/testThree
標準出力への表示を指定された TAPPlugin
を使用することもできます。ただし、標準出力に表示される他のテキスト (失敗したテストの情報など) がストリームに割り込むと、無効になる可能性があります。
バージョン履歴
R2016b で導入
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)