このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。
matlab.unittest.plugins.TAPPlugin.producingOriginalFormat
クラス: matlab.unittest.plugins.TAPPlugin
パッケージ: matlab.unittest.plugins
オリジナルの TAP 形式の TAPPlugin を作成
構文
説明
matlab.unittest.plugins.TAPPlugin.producingOriginalFormat
は、オリジナルの Test Anything Protocol (TAP) 形式 (バージョン 12) の出力を生成するプラグインを作成します。既定では、プラグインは ToStandardOutput
ストリームを使用し、出力が画面に表示されます。この場合、画面に送られる他の出力によって TAP ストリームが無効になる可能性があります。
matlab.unittest.plugins.TAPPlugin.producingOriginalFormat(
は、すべてのテキスト出力を指定された出力ストリームにリダイレクトします。たとえば、出力を stream
)ToFile
ストリームにリダイレクトできます。
matlab.unittest.plugins.TAPPlugin.producingOriginalFormat(___,
は、1 つ以上の Name,Value
)Name,Value
のペア引数で指定された追加オプションをもつプラグインを作成します。
入力引数
stream
— プラグインがテキスト出力を送信する場所
matlab.unittest.plugins.ToStandardOutput
(既定値) | matlab.unittest.plugins.OutputStream
クラスのインスタンス
プラグインがテキスト出力を送信する場所。OutputStream
クラスのインスタンスとして指定します。既定では、プラグインは ToStandardOutput
ストリームを使用します。
例: stream = matlab.unittest.plugins.ToStandardOutput
例: stream = matlab.unittest.plugins.ToFile('myFile.tap')
名前と値の引数
例: TAPPlugin.producingOriginalFormat('LoggingLevel', Verbosity.Detailed)
は Detailed
以下のレベルでログに記録された診断を含めるプラグインを作成します。
オプションの Name,Value
の引数ペアをコンマ区切りで指定します。Name
は引数名で、Value
は対応する値です。Name
は引用符で囲まなければなりません。Name1,Value1,...,NameN,ValueN
のように、複数の名前と値のペアの引数を任意の順序で指定できます。
IncludingPassingDiagnostics
— パスしたイベントの診断を含める
false
(既定値) | true
パスしたイベントの診断を含めるかどうか。false
または true
として指定します。既定で、プラグインはパスしたイベントの診断を含めません。
データ型: logical
LoggingLevel
— 診断ログの最大レベル
1 (既定値) | 0 | 2 | 3 | 4 | matlab.unittest.Verbosity
列挙型 | string または char ベクトルとしての列挙名
プラグイン インスタンスが含める診断ログの最大レベル。0 ~ 4 の整数値、matlab.unittest.Verbosity
列挙型オブジェクト、事前定義された列挙型メンバー名のいずれかに対応する string スカラーまたは文字ベクトルとして指定します。このプラグインは、このレベル以下でログに記録された診断を含めます。整数値は matlab.unittest.Verbosity
列挙型のメンバーに対応します。
数値表現 | 列挙型メンバー名 | 詳細レベルの説明 |
---|---|---|
0 | None | 情報なし |
1 | Terse | 最小限の情報 |
2 | Concise | 中程度の情報量 |
3 | Detailed | ある程度の補足的な情報 |
4 | Verbose | 多くの補足的な情報 |
既定で、プラグインは matlab.unittest.Verbosity.Terse
レベル (レベル 1) でログに記録された診断を含めます。診断ログを除外するには、LoggingLevel
を Verbosity.None
(レベル 0) に指定します。
診断ログとは、log (TestCase)
メソッドまたは log (Fixture)
メソッドの呼び出しによってテスト フレームワークに送る診断です。
OutputDetail
— レポートするイベントの詳細レベル
3 (既定値) | 0 | 1 | 2 | 4 | matlab.unittest.Verbosity
列挙型 | string または char ベクトルとしての列挙名
レポートするイベントの詳細レベル。0 ~ 4 の整数値、matlab.unittest.Verbosity
列挙型オブジェクト、事前定義された列挙型メンバー名のいずれかに対応する string スカラーまたは文字ベクトルとして指定します。整数値は matlab.unittest.Verbosity
列挙型のメンバーに対応します。
プラグインは、パスしたイベント、失敗したイベント、およびログに記録されたイベントを、OutputDetail
で指定された詳細レベルでレポートします。既定で、プラグインはイベントを matlab.unittest.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.unittest.plugins.ToFile suite = TestSuite.fromClass(?ExampleTest);
既定のプラグインを使用して、出力をコマンド ウィンドウに表示するテスト ランナーを作成します。
runner = TestRunner.withTextOutput;
出力を MyTapOutput.tap
ファイルに送信する TAPPlugin
を作成します。
tapFile = 'MyTAPOutput.tap';
plugin = TAPPlugin.producingOriginalFormat(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 values are not equal using "isequaln". --> Failure table: Actual Expected Error RelativeError ______ ________ _____ _____________ 5 4 1 0.25 Actual double: 5 Expected double: 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))
1..3 not ok 1 - ExampleTest/testOne # ================================================================================ # Verification failed in ExampleTest/testOne. # # ---------------- # Test Diagnostic: # ---------------- # Testing 5==4 # # --------------------- # Framework Diagnostic: # --------------------- # verifyEqual failed. # --> The values are not equal using "isequaln". # --> Failure table: # Actual Expected Error RelativeError # ______ ________ _____ _____________ # # 5 4 1 0.25 # # Actual double: # 5 # Expected double: # 4 # # ------------------ # Stack Information: # ------------------ # In C:\work\ExampleTest.m (ExampleTest.testOne) at 4 # ================================================================================ # ok 2 - ExampleTest/testTwo ok 3 - ExampleTest/testThree
標準出力への表示を指定された TAPPlugin
を使用することもできます。ただし、標準出力に表示される他のテキスト (失敗したテストの情報など) がストリームに割り込むと、無効になる可能性があります。
バージョン履歴
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)