matlab.unittest.qualifications.Assertable class
Package: matlab.unittest.qualifications
Qualification to validate preconditions of a test
Description
The Assertable
class provides a qualification to validate preconditions of
a test. Apart from actions performed for failures, the Assertable
class works
the same as other qualification classes in the matlab.unittest.qualifications
package.
Upon an assertion failure, the Assertable
class informs the testing
framework of the failure by throwing an AssertionFailedException
object. This behavior is most useful when a failure at the
assertion point renders the remainder of the current test invalid, but does not prevent proper
execution of subsequent tests. Often, you use assertions to ensure that preconditions of the
current test are not violated or that fixtures are set up correctly. If you cannot make the
fixture teardown exception safe or
restore the environment state after failure, use fatal assertions instead.
When an assertion failure is produced within a method of the TestCase
class, the type of the method determines which tests are affected:
Test
method — The framework marks the entireTest
method as failed and incomplete.TestMethodSetup
orTestMethodTeardown
method — The framework marks theTest
method to run for that method instance as failed and incomplete.TestClassSetup
orTestClassTeardown
method — The framework marks the entire test class as failed and incomplete.
Assertions let remaining tests receive coverage when preconditions are violated in a test but the state is recoverable. They prevent unnecessary failures by not performing later verifications that fail due to invalidated preconditions. If the failure does not affect the preconditions of the test or cause problems with fixture setup or teardown, use verifications, which ensure that the full test content runs.
The matlab.unittest.qualifications.Assertable
class is a handle
class.
Methods
Events
Event Name | Trigger | Event Data | Event Attributes |
---|---|---|---|
AssertionFailed | Triggered upon failing assertion. A QualificationEventData
object is passed to listener callback functions. | matlab.unittest.qualifications.QualificationEventData |
|
AssertionPassed | Triggered upon passing assertion. A QualificationEventData
object is passed to listener callback functions. | matlab.unittest.qualifications.QualificationEventData |
|
Examples
More About
Version History
Introduced in R2013a