Main Content

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 TestForm of Method NameExample
Value is true.<qualify>TrueverifyTrue
Value is false.<qualify>FalseverifyFalse
Value is equal to the specified value.<qualify>EqualverifyEqual
Value is not equal to the specified value.<qualify>NotEqualverifyNotEqual
Two values are handles to the same instance.<qualify>SameHandleverifySameHandle
Value is not a handle to the specified instance.<qualify>NotSameHandleverifyNotSameHandle
Function returns true.<qualify>ReturnsTrueverifyReturnsTrue
Test produces an unconditional failure.<qualify>FailverifyFail
Value meets the specified constraint.<qualify>ThatverifyThat

Errors and Warnings

Type of TestForm of Method NameExample
Function throws the specified exception.<qualify>ErrorverifyError
Function issues the specified warning.<qualify>WarningverifyWarning
Function issues no warnings.<qualify>WarningFreeverifyWarningFree

Inequalities

Type of TestForm of Method NameExample
Value is greater than the specified value.<qualify>GreaterThanverifyGreaterThan
Value is greater than or equal to the specified value.<qualify>GreaterThanOrEqualverifyGreaterThanOrEqual
Value is less than the specified value.<qualify>LessThanverifyLessThan
Value is less than or equal to the specified value.<qualify>LessThanOrEqualverifyLessThanOrEqual

Array Size

Type of TestForm of Method NameExample
Value is empty.<qualify>EmptyverifyEmpty
Value is not empty.<qualify>NotEmptyverifyNotEmpty
Value has the specified size.<qualify>SizeverifySize
Value has the specified length.<qualify>LengthverifyLength
Value has the specified element count.<qualify>NumElementsverifyNumElements

Type

Type of TestForm of Method NameExample
Class of value is the specified class.<qualify>ClassverifyClass
Value is an instance of the specified class.<qualify>InstanceOfverifyInstanceOf

Strings

Type of TestForm of Method NameExample
Value contains the specified string.<qualify>SubstringverifySubstring
Value matches the specified regular expression.<qualify>MatchesverifyMatches

See Also

| | | |