Package: matlab.unittest
Superclass of all matlab.unittest
test classes
The TestCase
class is the means by which a test is written in the
matlab.unittest
framework. It provides the means to write and
identify test content, as well as test fixture setup and teardown routines. Creating
such a test requires deriving from TestCase
to produce a
TestCase
subclass. Then, subclasses can leverage the metadata
attributes to specify tests and test fixtures.
Use the forInteractiveUse
static method to create a
TestCase
for interactive, command line use. When tests are run in the
framework, TestCase
instances are constructed by the
matlab.unittest.TestRunner
.
addTeardown | Dynamically add teardown routine to TestCase instance |
applyFixture | Use fixture with TestCase |
forInteractiveUse | Create TestCase for interactive use |
getSharedTestFixtures | Provide access to shared test fixtures |
log | Record diagnostic information during test execution |
onFailure | Dynamically add diagnostics for test failures |
run | Run TestCase test |
The TestCase
class inherits methods from the following
classes:
matlab.unittest.qualifications.Assertable | Qualification to validate preconditions of a test |
matlab.unittest.qualifications.Assumable | Qualification to filter test content |
matlab.unittest.qualifications.FatalAssertable | Qualification to abort test execution |
matlab.unittest.qualifications.Verifiable | Qualification to produce soft failure conditions |
TestCase
objects support the following class level attributes.
Specify class-level attributes in the classdef
block before the
class name.
SharedTestFixtures | Class block to contain shared test fixtures. You must define
SharedTestFixtures as a cell array of
matlab.unittest.fixtures.Fixture
instances. |
TestTags | Class block to contain tests tagged with a specified value. You
must define TestTags as a cell array of non-empty
character vectors or an array of non-empty strings, where each
element is a tag for the test. |
Classes that derive from TestCase
can define
methods
blocks which contain
matlab.unittest
framework-specific attributes to specify test
content.
Test | Method block to contain test methods. |
TestMethodSetup | Method block to contain setup code. |
TestMethodTeardown | Method block to contain teardown code. |
TestClassSetup | Method block to contain class level setup code. |
TestClassTeardown | Method block to contain class level teardown code. |
ParameterCombination | Method block to contain parameterized testing code. This attribute accepts the following values:
|
TestTags | Method block to contain tests tagged with a specified value. You
must define TestTags as a cell array of non-empty
character vectors or an array of non-empty strings, where each
element is a tag for the test. |
Classes that derive from TestCase
can define
properties
blocks which contain
matlab.unittest
framework-specific attributes to specify test
content.
ClassSetupParameter | Property block to define parameterized testing properties for
methods in the TestClassSetup block |
MethodSetupParameter | Property block to define parameterized testing properties for
methods in the TestMethodSetup block |
TestParameter | Property block to define parameterized testing properties for
methods in the Test block |
VerificationFailed | Triggered upon failing verification. A
|
VerificationPassed | Triggered upon passing verification. A
|
AssertionFailed | Triggered upon failing assertion. A
|
AssertionPassed | Triggered upon passing assertion. A
|
FatalAssertionFailed | Triggered upon failing fatal assertion. A
|
FatalAssertionPassed | Triggered upon passing fatal assertion. A
|
AssumptionFailed | Triggered upon failing assumption. A
|
AssumptionPassed | Triggered upon passing assumption. A
|
ExceptionThrown | Triggered by the |
DiagnosticLogged | Triggered by the |
addlistener
| matlab.unittest.constraints
| matlab.unittest.diagnostics.LoggedDiagnosticEventData
| matlab.unittest.qualifications
| matlab.unittest.qualifications.ExceptionEventData
| matlab.unittest.qualifications.QualificationEventData
| TestRunner