В вашей рабочей папке создайте testZeros.m. Этот класс содержит четыре метода тестирования.
Тестовый класс содержит два параметризованных метода тестирования, testClass и testSize.
В командной строке создайте тестовый набор из файла.
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' }Комплект содержит 11 тестовых элементов. Шесть из параметризованного метода testClass, два из параметризованного метода testSize, и один от каждого testDefaultClass, testDefaultSize и методов testDefaultValue.
Выберите все тестовые элементы от параметризованных методов тестирования.
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)' }Комплект содержит восемь тестовых элементов от двух параметризованных методов тестирования.
Выберите все тестовые элементы от непараметризованных методов тестирования.
ans =
3×1 cell array
{'testZeros/testDefaultClass'}
{'testZeros/testDefaultSize' }
{'testZeros/testDefaultValue'}Выберите все тестовые элементы, которые параметризованы и имеют свойство под названием 'type' с названием параметра 'double'.
ans =
2×1 cell array
{'testZeros/testClass(type=double,outSize=s2d)'}
{'testZeros/testClass(type=double,outSize=s3d)'}Получившийся комплект содержит два элемента. Метод testClass является единственным методом в testZeros, который использует свойство 'type' и выбор только 'double' от результатов параметров в двух тестовых элементах — один для каждого значения 'outSize'.
Выберите все тестовые элементы, которые параметризованы и имеют параметры, заданные свойством начиная с '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)'}Получившийся комплект содержит шесть параметризованных тестовых элементов из метода testClass. Метод testSize параметризован, но элементы из метода не включены в комплект, потому что метод не использует свойство, которое запускается с 't'.
Выберите все тестовые элементы, которые параметризованы и тестируют функцию zeros с массивом 2-D. Значение параметров, представляющее массив 2-D, будет иметь длину 1 (например, zeros(3)) или 2 (например, 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)' }Выберите только тестовый элемент, который тестирует это, вывод является типом данных double и правильного размера для массива 2-D.
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.