MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
ParameterCombinatio
n Attribute

Method Invocation

'pairwise' Methods are invoked for every pair of parameter values at
least once. While the test framework guarantees that tests are
created for every pair of values at least once, you should not
rely on that size, ordering, or specific set of test suite
elements.

For example, use the combined methods attribute TestMethodSetup,
ParameterCombination='sequential' to specify sequential combination of the
method setup-level parameters defined in the MethodSetupParameter properties block.


For this example, class setup-level parameterization defines the type of random number
generator. The method setup-level parameterization defines the seed for the random
number generator, and the test-level parameterization defines the data type and size of
the random number output.


Create TestRand Test Class


In a file in your working folder, create a class that inherits from
matlab.unittest.TestCase. This class tests various aspects of random number
generation.


classdef TestRand < matlab.unittest.TestCase


Define properties Blocks


Define the properties used for parameterized testing. Each properties block
corresponds to parameterization at a particular level.


properties (ClassSetupParameter)
generator = {'twister','combRecursive','multFibonacci'};
end


properties (MethodSetupParameter)
seed = {0, 123, 4294967295};
end


properties (TestParameter)
dim1 = struct('small', 1,'medium', 2, 'large', 3);
dim2 = struct('small', 2,'medium', 3, 'large', 4);
dim3 = struct('small', 3,'medium', 4, 'large', 5);


Create Advanced Parameterized Test
Free download pdf