In your working folder, create testZeros.m
.
This class contains four test methods.
The test class contains two parameterized test methods, testClass
and testSize
.
At the command prompt, create a test suite from the file.
ans =
11×1 cell array
{'testZeros/testClass(type=single,outSize=s2d)'}
{'testZeros/testClass(type=single,outSize=s3d)'}
{'testZeros/testClass(type=double,outSize=s2d)'}
{'testZeros/testClass(type=double,outSize=s3d)'}
{'testZeros/testClass(type=uint16,outSize=s2d)'}
{'testZeros/testClass(type=uint16,outSize=s3d)'}
{'testZeros/testSize(outSize=s2d)' }
{'testZeros/testSize(outSize=s3d)' }
{'testZeros/testDefaultClass' }
{'testZeros/testDefaultSize' }
{'testZeros/testDefaultValue' }
The suite contains 11 test elements. Six from the parameterized testClass
method,
two from the parameterized testSize
method, and
one from each of the testDefaultClass
, testDefaultSize
,
and testDefaultValue
methods.
Select all of the test elements from parameterized test
methods.
ans =
8×1 cell array
{'testZeros/testClass(type=single,outSize=s2d)'}
{'testZeros/testClass(type=single,outSize=s3d)'}
{'testZeros/testClass(type=double,outSize=s2d)'}
{'testZeros/testClass(type=double,outSize=s3d)'}
{'testZeros/testClass(type=uint16,outSize=s2d)'}
{'testZeros/testClass(type=uint16,outSize=s3d)'}
{'testZeros/testSize(outSize=s2d)' }
{'testZeros/testSize(outSize=s3d)' }
The suite contains the eight test elements from the two parameterized
test methods.
Select all of the test elements from non-parameterized
test methods.
ans =
3×1 cell array
{'testZeros/testDefaultClass'}
{'testZeros/testDefaultSize' }
{'testZeros/testDefaultValue'}
Select all test elements that are parameterized and have
a property named 'type'
with a parameter name 'double'
.
ans =
2×1 cell array
{'testZeros/testClass(type=double,outSize=s2d)'}
{'testZeros/testClass(type=double,outSize=s3d)'}
The resulting suite contains two elements. The testClass
method
is the only method in testZeros
that uses the 'type'
property,
and selecting only 'double'
from the parameters
results in two test elements — one for each value of 'outSize'
.
Select all test elements that are parameterized and have
a parameters defined by a property starting with 't'
.
ans =
6×1 cell array
{'testZeros/testClass(type=single,outSize=s2d)'}
{'testZeros/testClass(type=single,outSize=s3d)'}
{'testZeros/testClass(type=double,outSize=s2d)'}
{'testZeros/testClass(type=double,outSize=s3d)'}
{'testZeros/testClass(type=uint16,outSize=s2d)'}
{'testZeros/testClass(type=uint16,outSize=s3d)'}
The resulting suite contains the six parameterized test elements
from the testClass
method. The testSize
method
is parameterized, but the elements from the method are not included
in the suite because the method does not use a property that starts
with 't'
.
Select all test elements that are parameterized and test
the zeros
function with a 2-D
array.
A parameter value representing a 2-D
array will
have a length of 1
(e.g. zeros(3)
)
or 2
(e.g. zeros(2,3)
).
ans =
4×1 cell array
{'testZeros/testClass(type=single,outSize=s2d)'}
{'testZeros/testClass(type=double,outSize=s2d)'}
{'testZeros/testClass(type=uint16,outSize=s2d)'}
{'testZeros/testSize(outSize=s2d)' }
Select only the test element that tests that the output
is a double
data type and the has the correct size
for a 2-D
array.
s6 =
Test with properties:
Name: 'testZeros/testClass(type=double,outSize=s2d)'
ProcedureName: 'testClass'
TestClass: "testZeros"
BaseFolder: 'C:\work'
Parameterization: [1×2 matlab.unittest.parameters.TestParameter]
SharedTestFixtures: [0×0 matlab.unittest.fixtures.EmptyFixture]
Tags: {1×0 cell}
Tests Include:
2 Unique Parameterizations, 0 Shared Test Fixture Classes, 0 Tags.