このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
matlab.unittest.parameters.Parameter クラス
名前空間: matlab.unittest.parameters
パラメーターの基底クラス
説明
パラメーター化されたテストで、パラメーターを使用してデータをテスト メソッドに渡します。
構築
静的な fromData メソッドを使用して、Parameter をインスタンス化します。
プロパティ
この プロパティ は読み取り専用です。
Parameter を定義するプロパティの名前。文字ベクトルとして格納されます。
この プロパティ は読み取り専用です。
パラメーター値の名前。文字ベクトルとして格納されます。Name はパラメーターの特定の値を一意に識別します。
この プロパティ は読み取り専用です。
パラメーター値。任意の配列タイプとして格納されます。Value には、パラメーター化されたメソッドに TestRunner が渡すデータが格納されます。
メソッド
| fromData | データからパラメーターを作成 |
コピーのセマンティクス
値。値クラスがコピー操作に与える影響については、オブジェクトのコピーを参照してください。
例
作業フォルダーで testZeros.m を作成します。このクラスには 5 つのテスト メソッドがあり、パラメーター化されたテストが 11 個生成されます。
classdef testZeros < matlab.unittest.TestCase properties (TestParameter) type = {'single','double','uint16'}; outSize = struct('s2d',[3 3], 's3d',[2 5 4]); end methods (Test) function testClass(testCase, type, outSize) testCase.verifyClass(zeros(outSize,type), type); end function testSize(testCase, outSize) testCase.verifySize(zeros(outSize), outSize); end function testDefaultClass(testCase) testCase.verifyClass(zeros, 'double'); end function testDefaultSize(testCase) testCase.verifySize(zeros, [1 1]); end function testDefaultValue(testCase) testCase.verifyEqual(zeros,0); end end end
テストで single、double、uint16 ではなく uint64 および int64 データ型をパラメーター化に使用するよう、type パラメーターを再定義します。パラメーターを作成します。
import matlab.unittest.parameters.Parameter newType = {'int64','uint64'}; param = Parameter.fromData('type',newType);
param パラメーターを挿入するテスト スイートを作成します。スイート内のテストの名前を表示します。挿入されたパラメーターは #ext で表されます。
import matlab.unittest.TestSuite suite = TestSuite.fromClass(?testZeros,'ExternalParameters',param); {suite.Name}'
ans =
9×1 cell array
{'testZeros/testClass(type=int64#ext,outSize=s2d)' }
{'testZeros/testClass(type=int64#ext,outSize=s3d)' }
{'testZeros/testClass(type=uint64#ext,outSize=s2d)'}
{'testZeros/testClass(type=uint64#ext,outSize=s3d)'}
{'testZeros/testSize(outSize=s2d)' }
{'testZeros/testSize(outSize=s3d)' }
{'testZeros/testDefaultClass' }
{'testZeros/testDefaultSize' }
{'testZeros/testDefaultValue' }
スイートを実行します。
results = suite.run;
Running testZeros ......... Done testZeros __________
テストで 1 次元の配列と 4 次元の配列がパラメーター化されるよう、outSize パラメーターを再定義します。newType と newSize からパラメーターを作成します。
newSize = struct('s2d',[5 3],'s4d',[2 3 2 4]); param = Parameter.fromData('type',newType,'outSize',newSize);
param パラメーターを挿入するテスト スイートを作成します。スイート内のテストの名前を表示します。挿入されたパラメーターは #ext で表されます。
import matlab.unittest.TestSuite suite = TestSuite.fromClass(?testZeros,'ExternalParameters',param); {suite.Name}'
ans =
9×1 cell array
{'testZeros/testClass(type=int64#ext,outSize=s2d#ext)' }
{'testZeros/testClass(type=int64#ext,outSize=s4d#ext)' }
{'testZeros/testClass(type=uint64#ext,outSize=s2d#ext)'}
{'testZeros/testClass(type=uint64#ext,outSize=s4d#ext)'}
{'testZeros/testSize(outSize=s2d#ext)' }
{'testZeros/testSize(outSize=s4d#ext)' }
{'testZeros/testDefaultClass' }
{'testZeros/testDefaultSize' }
{'testZeros/testDefaultValue' }
スイートを実行します。
results = suite.run;
Running testZeros ......... Done testZeros __________
バージョン履歴
R2018b で導入
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)