Package: matlab.unittest.qualifications
Qualification to validate preconditions of a test
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 matlab.unittest
qualifications.
Upon an assertion failure, the Assertable
class
throws an AssertionFailedException
to inform the
testing framework of the failure. This is most useful when a failure
at the assertion point renders the rest of the current test method
invalid, yet does not prevent proper execution of other test methods.
Often, you use assertions to ensure that preconditions of the current
test are not violated or that fixtures are set up correctly. Make
sure the test content is Exception Safe.
If you cannot make the fixture teardown exception safe or if you cannot
recover it after failure, use fatal assertions instead.
Use assertions to allow remaining test methods to receive coverage when preconditions are violated in a test and all fixture states are restorable. Assertions also reduce the noise level of failures by not performing later verifications that fail due the precondition failures. In the event of a failure, however, the test framework marks the full content of the test method that failed as incomplete. Therefore, if the failure does not affect the preconditions of the test or cause problems with fixture setup or teardown, use verifications, which give the added information that the full test content was run.
assertClass | Assert exact class of specified value |
assertEmpty | Assert value is empty |
assertEqual | Assert value is equal to specified value |
assertError | Assert function throws specified exception |
assertFail | Produce unconditional assertion failure |
assertFalse | Assert value is false |
assertGreaterThan | Assert value is greater than specified value |
assertGreaterThanOrEqual | Assert value is greater than or equal to specified value |
assertInstanceOf | Assert value is object of specified type |
assertLength | Assert value has specified length |
assertLessThan | Assert value is less than specified value |
assertLessThanOrEqual | Assert value is less than or equal to specified value |
assertMatches | Assert string matches specified regular expression |
assertNotEmpty | Assert value is not empty |
assertNotEqual | Assert value is not equal to specified value |
assertNotSameHandle | Assert value is not handle to specified instance |
assertNumElements | Assert value has specified element count |
assertReturnsTrue | Assert function returns true when evaluated |
assertSameHandle | Assert two values are handles to same instance |
assertSize | Assert value has specified size |
assertSubstring | Assert string contains specified string |
assertThat | Assert that value meets specified constraint |
assertTrue | Assert value is true |
assertWarning | Assert function issues specified warnings |
assertWarningFree | Assert function issues no warnings |
AssertionFailed | Triggered upon failing assertion. A |
AssertionPassed | Triggered upon passing assertion. A |
Handle. To learn how handle classes affect copy operations, see Copying Objects.
Assumable
| FatalAssertable
| matlab.unittest.qualifications
| QualificationEventData
| TestCase
| Verifiable