functiontests
ローカル関数へのハンドルからのテストの配列の作成
説明
例
テスト配列の作成
MATLAB® パスにファイル exampleTest.m
を作成します。メイン関数で、テスト配列を作成します。ローカル関数を使用して、セットアップ、破棄および関数のテスト 2 つを定義します。使用するファイルは次のようになります。
function tests = exampleTest tests = functiontests(localfunctions); function setup(testCase) function teardown(testCase) function exampleOneTest(testCase) function testExampleTwo(testCase)
コマンド ラインで、関数 exampleTest
を呼び出します。
tests = exampleTest
tests = 1x2 Test array with properties: Name ProcedureName TestClass BaseFolder Parameterization SharedTestFixtures Tags Tests Include: 0 Parameterizations, 0 Shared Test Fixture Classes, 0 Tags.
テスト スイートにアクセスして、2 つの関数テストの名前を確認します。
tests.Name
ans = 'exampleTest/exampleOneTest' ans = 'exampleTest/testExampleTwo'
入力引数
f
— ローカル テスト関数へのハンドル
関数ハンドルの cell 配列
ローカル テスト関数へのハンドル。cell 配列として指定します。作業ファイルの f=localfunctions
を使用して、そのファイルへの関数ハンドルの cell 配列を自動的に生成します。明示的なテスト列挙が必要な場合は、個々の関数をリストすることによって、f
を構築します。f
には、テストに必要なセットアップまたは破棄関数を組み込まなければなりません。
例: f = localfunctions;
例: f = {@setup,@exampleOneTest,@teardown};
バージョン履歴
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)