MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
end
end

Qualifications are methods for testing values and responding to failures. This table lists
the types of qualifications.

Verifica
tions

Use this qualification to
produce and record failures
without throwing an
exception. The remaining
tests run to completion.

matlab.unittest.qualifications.Verifi
able

Assump
tions

Use this qualification to
ensure that a test runs only
when certain preconditions
are satisfied. However,
running the test without
satisfying the preconditions
does not produce a test
failure. When an assumption
failure occurs, the testing
framework marks the test as
filtered.

matlab.unittest.qualifications.Assuma
ble

Asserti
ons

Use this qualification to
ensure that the preconditions
of the current test are met.

matlab.unittest.qualifications.Assert
able

Fatal
assertio
ns

Use this qualification when
the failure at the assertion
point renders the remainder
of the current test method
invalid or the state is
unrecoverable.

matlab.unittest.qualifications.FatalA
ssertable

The MATLAB Unit Testing Framework provides approximately 25 qualification methods
for each type of qualification. For example, use verifyClass or assertClass to test
that a value is of an expected class, and use assumeTrue or fatalAssertTrue to test if
the actual value is true. For a summary of qualification methods, see “Types of
Qualifications” on page 33-60.

Often, each unit test function obtains an actual value by exercising the code that you are
testing and defines the associated expected value. For example, if you are testing the

33 Unit Testing

Free download pdf