'TestClean/noZeroCheck(Data=needsCleaning)' true false false 0.0093186 [1×1 struct]
Create a data set external to the test file.
A = [NaN 2 0;1 Inf 3];
Create a parameter with the external data set. The fromData method accepts the name
of the parameterized property from the properties block in TestClean and the new
data as a cell array (or struct).
import matlab.unittest.parameters.Parameter
newData = {A};
param = Parameter.fromData('Data',newData);
Create and a new test suite and view the suite element names. The fromClass method
accepts the new parameter.
suite2 = TestSuite.fromClass(?TestClean,'ExternalParameters',param);
{suite2.Name}'
ans =
4×1 cell array
{'TestClean/classCheck(Data=value1#ext)' }
{'TestClean/sortCheck(Data=value1#ext)' }
{'TestClean/finiteCheck(Data=value1#ext)'}
{'TestClean/noZeroCheck(Data=value1#ext)'}
Using the external parameter, the framework creates four suite elements. Since the
parameters are defined as a cell array, MATLAB generates the parameter name (value1).
Also, it appends the characters #ext to the end of the parameter name, indicating the
parameter is defined externally.
To assign meaningful parameter names (instead of valueN), define the parameter using a
struct. View the suite element names and run the tests.
newData = struct('commandLineData',A);
param = Parameter.fromData('Data',newData);
suite2 = TestSuite.fromClass(?TestClean,'ExternalParameters',param);
{suite2.Name}'
results = suite2.run;
Use External Parameters in Parameterized Test