VerificationTest

VerificationTest[input]

runs a verification test to determine whether input evaluates to True.

VerificationTest[input,expected]

tests whether input evaluates to expected, without issuing messages.

VerificationTest[input,expected,messages]

tests whether input evaluates to expected, generating the list of message names messages.

Details and Options

Examples

open allclose all

Basic Examples  (4)

Test whether the input evaluates to True:

Test whether the input evaluates to the expected output:

When a test fails, it returns an output of Failure:

When the input evaluates to the expected output but gives messages, the outcome is going to be MessagesFailure:

Add the expected message:

Scope  (2)

Basic Uses  (2)

Perform a test and present the results in a Dataset:

Test if the results of an NIntegrate are numerically equivalent to Integrate, by using an absolute tolerance:

This can also be done by using the SameTest option:

Options  (13)

MemoryConstraint  (1)

Run a test until a memory limit is exceeded:

SameTest  (5)

Test whether the input is an integer:

Test if the absolute precision of the input is at least 10-12:

Test if the relative precision is at least 10-5:

Test if two expressions are equivalent after simplification:

Use Unevaluated to pass unevaluated expressions to the SameTest function:

You can use a combination of Function and Echo to print the arguments of the SameTest function:

TestID  (4)

Add TestID to a VerificationTest:

A TestID can be any expression:

By default, the TestID is a Hash of the test:

The TestID will change if the input of the TestCreate expression is different:

Use CreateUUID to create random identifiers every time:

TimeConstraint  (1)

Terminate the test if it takes more than one second:

MetaInformation  (2)

Store arbitrary metainformation in the TestObject:

Access the stored MetaInformation:

MetaInformation can be any expression:

Possible Issues  (3)

The expected output is evaluated before comparison with the actual output:

Use Unevaluated to compare expressions before evaluation happens:

Messages generated on evaluation of expected output are not accounted for in the expected messages:

If SameTest does not evaluate to True or False, a failure type of "SameTestUnevaluated" is reported:

Wolfram Research (2014), VerificationTest, Wolfram Language function, https://reference.wolfram.com/language/ref/VerificationTest.html (updated 2023).

Text

Wolfram Research (2014), VerificationTest, Wolfram Language function, https://reference.wolfram.com/language/ref/VerificationTest.html (updated 2023).

CMS

Wolfram Language. 2014. "VerificationTest." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/VerificationTest.html.

APA

Wolfram Language. (2014). VerificationTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VerificationTest.html

BibTeX

@misc{reference.wolfram_2024_verificationtest, author="Wolfram Research", title="{VerificationTest}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/VerificationTest.html}", note=[Accessed: 28-February-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_verificationtest, organization={Wolfram Research}, title={VerificationTest}, year={2023}, url={https://reference.wolfram.com/language/ref/VerificationTest.html}, note=[Accessed: 28-February-2024 ]}