Table of Verifications, Assertions, and Other Qualifications
There are four types of qualifications for testing values and responding to failures: verifications, assumptions, assertions, and fatal assertions.
Verifications — Produce and record failures without returning an exception. When a verification failure occurs, the remaining tests run to completion.
Assumptions — Ensure that the test environment meets preconditions that otherwise do not result in a test failure. When an assumption failure occurs, the testing framework marks the test as filtered.
Assertions — Ensure that the preconditions of the current test are met. When an assertion failure occurs, the framework marks the current test as failed and incomplete. However, the failure does not prevent the execution of subsequent tests.
Fatal assertions — Ensure that the remainder of the current test session is valid and the state is recoverable. When a fatal assertion failure occurs, the testing framework aborts the test session.
These qualification types have parallel methods for the same types of tests. The
methods use a common naming convention. For instance, the methods that test for a true
value use the form <qualify>
True
, where
<qualify>
can be verify
,
assume
, assert
, or
fatalAssert
. That is:
verifyTrue
— Verify value is true.assumeTrue
— Assume value is true.assertTrue
— Assert value is true.fatalAssertTrue
— Fatally assert value is true.
General Purpose
Type of Test | Form of Method Name | Example |
---|---|---|
Value is true. | <qualify> True | verifyTrue |
Value is false. | <qualify> False | verifyFalse |
Value is equal to the specified value. | <qualify> Equal | verifyEqual |
Value is not equal to the specified value. | <qualify> NotEqual | verifyNotEqual |
Two values are handles to the same instance. | <qualify> SameHandle | verifySameHandle |
Value is not a handle to the specified instance. | <qualify> NotSameHandle | verifyNotSameHandle |
Function returns true. | <qualify> ReturnsTrue | verifyReturnsTrue |
Test produces an unconditional failure. | <qualify> Fail | verifyFail |
Value meets the specified constraint. | <qualify> That | verifyThat |
Errors and Warnings
Type of Test | Form of Method Name | Example |
---|---|---|
Function throws the specified exception. | <qualify> Error | verifyError |
Function issues the specified warning. | <qualify> Warning | verifyWarning |
Function issues no warnings. | <qualify> WarningFree | verifyWarningFree |
Inequalities
Type of Test | Form of Method Name | Example |
---|---|---|
Value is greater than the specified value. | <qualify> GreaterThan | verifyGreaterThan |
Value is greater than or equal to the specified value. | <qualify> GreaterThanOrEqual | verifyGreaterThanOrEqual |
Value is less than the specified value. | <qualify> LessThan | verifyLessThan |
Value is less than or equal to the specified value. | <qualify> LessThanOrEqual | verifyLessThanOrEqual |
Array Size
Type of Test | Form of Method Name | Example |
---|---|---|
Value is empty. | <qualify> Empty | verifyEmpty |
Value is not empty. | <qualify> NotEmpty | verifyNotEmpty |
Value has the specified size. | <qualify> Size | verifySize |
Value has the specified length. | <qualify> Length | verifyLength |
Value has the specified element count. | <qualify> NumElements | verifyNumElements |
Type
Type of Test | Form of Method Name | Example |
---|---|---|
Class of value is the specified class. | <qualify> Class | verifyClass |
Value is an instance of the specified class. | <qualify> InstanceOf | verifyInstanceOf |
Strings
Type of Test | Form of Method Name | Example |
---|---|---|
Value contains the specified string. | <qualify> Substring | verifySubstring |
Value matches the specified regular expression. | <qualify> Matches | verifyMatches |
See Also
matlab.unittest.qualifications.Verifiable
| matlab.unittest.qualifications.Assumable
| matlab.unittest.qualifications.Assertable
| matlab.unittest.qualifications.FatalAssertable
| matlab.unittest.qualifications