MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Create Advanced Parameterized Test


This example shows how to create a test that is parameterized in the TestClassSetup,
TestMethodSetup, and Test methods blocks. The example test class tests the random
number generator.

Test Overview

The TestRand test class is parameterized at three different levels.

Parameterization
Level

Parameterization Definition Accessible
Parameterization
Properties

Method Attribute Property Attribute

Test level Test TestParameter TestParameter,
MethodSetupParam
eter, and
ClassSetupParame
ter
Method setup level TestMethodSetup MethodSetupParam
eter

MethodSetupParam
eter and
ClassSetupParame
ter
Class setup level TestClassSetup ClassSetupParame
ter

ClassSetupParame
ter

At each test level, you can use the ParameterCombination method attribute to specify
the test parameterization.

ParameterCombinatio
n Attribute

Method Invocation

'exhaustive' (default)Methods are invoked for all combinations of parameters. The
test framework uses this default combination if you do not
specify the ParameterCombination attribute.
'sequential' Methods are invoked with corresponding values from each
parameter. Each parameter must contain the same number of
values.

33 Unit Testing

Free download pdf