run
クラス: matlab.unittest.TestRunner
パッケージ: matlab.unittest
テスト スイートを実行
説明
入力引数
runner
— テスト ランナー
matlab.unittest.TestRunner
オブジェクト
テスト ランナー。matlab.unittest.TestRunner
オブジェクトとして指定します。
suite
— テスト スイート
matlab.unittest.TestSuite
配列
テスト スイート。matlab.unittest.TestSuite
配列として指定します。
出力引数
results
— 実行中のテスト スイートの結果
matlab.unittest.TestResult
配列
テスト スイートの実行結果。matlab.unittest.TestResult
配列として返されます。results
の要素は suite
の要素に対応します。
例
コマンド ウィンドウでのテスト結果の表示
テキスト出力用に構成されたテスト ランナーでテスト スイートを実行します。
現在のフォルダーに関数ベースのテスト sampleTest.m
を作成します。
function tests = sampleTest tests = functiontests(localfunctions); end function testA(testCase) % Test passes verifyEqual(testCase,2+3,5) end function testB(testCase) % Test fails verifyGreaterThan(testCase,13,42) end function testC(testCase) % Test passes verifySubstring(testCase,"Hello world!","llo") end
sampleTest.m
のテストからテスト スイートを作成します。
suite = testsuite("sampleTest.m");
テキスト出力を生成するテスト ランナーを作成し、それを使用してテストを実行します。テキスト出力には、テスト実行の進行状況とテスト失敗時の診断が含まれます。
runner = testrunner("textoutput");
results = run(runner,suite);
Running sampleTest . ================================================================================ Verification failed in sampleTest/testB. --------------------- Framework Diagnostic: --------------------- verifyGreaterThan failed. --> The value must be greater than the minimum value. Actual Value: 13 Minimum Value (Exclusive): 42 ------------------ Stack Information: ------------------ In C:\work\sampleTest.m (testB) at 10 ================================================================================ .. Done sampleTest __________ Failure Summary: Name Failed Incomplete Reason(s) =============================================================== sampleTest/testB X Failed by verification.
失敗したテストの結果を表示します。
disp(results([results.Failed]))
TestResult with properties: Name: 'sampleTest/testB' Passed: 0 Failed: 1 Incomplete: 0 Duration: 1.2982 Details: [1×1 struct] Totals: 0 Passed, 1 Failed (rerun), 0 Incomplete. 1.2982 seconds testing time.
バージョン履歴
R2013a で導入
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)