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 throwing an exception, meaning the remaining tests run to completion.

  • Assumptions — Ensure that a test runs only when certain preconditions are satisfied and the event should not produce 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.

  • Fatal assertions — Use this qualification when the failure at the assertion point renders the remainder of the current test method invalid or the state is unrecoverable.

Type of TestVerificationAssumptionAssertionFatal Assertion
Value is true.verifyTrueassumeTrueassertTruefatalAssertTrue
Value is false.verifyFalseassumeFalseassertFalsefatalAssertFalse
Value is equal to specified value.verifyEqualassumeEqualassertEqualfatalAssertEqual
Value is not equal to specified value.verifyNotEqualassumeNotEqualassertNotEqualfatalAssertNotEqual
Two values are handles to same instance.verifySameHandleassumeSameHandleassertSameHandlefatalAssertSameHandle
Value is not handle to specified instance.verifyNotSameHandleassumeNotSameHandleassertNotSameHandlefatalAssertNotSameHandle
Function returns true when evaluated.verifyReturnsTrueassumeReturnsTrueassertReturnsTruefatalAssertReturnsTrue
Test produces unconditional failure.verifyFailassumeFailassertFailfatalAssertFail
Value meets given constraint.verifyThatassumeThatassertThatfatalAssertThat
Value is greater than specified value.verifyGreaterThanassumeGreaterThanassertGreaterThanfatalAssertGreaterThan
Value is greater than or equal to specified value.verifyGreaterThanOrEqualassumeGreaterThanOrEqualassertGreaterThanOrEqualfatalAssertGreaterThanOrEqual
Value is less than specified value.verifyLessThanassumeLessThanassertLessThanfatalAssertLessThan
Value is less than or equal to specified value.verifyLessThanOrEqualassumeLessThanOrEqualassertLessThanOrEqualfatalAssertLessThanOrEqual
Value is exact specified class.verifyClassassumeClassassertClassfatalAssertClass
Value is object of specified type.verifyInstanceOfassumeInstanceOfassertInstanceOffatalAssertInstanceOf
Value is empty.verifyEmptyassumeEmptyassertEmptyfatalAssertEmpty
Value is not empty.verifyNotEmptyassumeNotEmptyassertNotEmptyfatalAssertNotEmpty
Value has specified size.verifySizeassumeSizeassertSizefatalAssertSize
Value has specified length.verifyLengthassumeLengthassertLengthfatalAssertLength
Value has specified element count.verifyNumElementsassumeNumElementsassertNumElementsfatalAssertNumElements
String contains specified string.verifySubstringassumeSubstringassertSubstringfatalAssertSubstring
Text matches specified regular expression.verifyMatchesassumeMatchesassertMatchesfatalAssertMatches
Function throws specified exception.verifyErrorassumeErrorassertErrorfatalAssertError
Function issues specified warning.verifyWarningassumeWarningassertWarningfatalAssertWarning
Function issues no warnings.verifyWarningFreeassumeWarningFreeassertWarningFreefatalAssertWarningFree

See Also

| | | |