({{, (RefLink[VerificationTest, paclet:ref/VerificationTest])[input] 
runs a verification test to determine whether input evaluates to (RefLink[True, paclet:ref/True]), without issuing messages.}, {, (RefLink[VerificationTest, paclet:ref/VerificationTest])[input,expected]
tests whether input evaluates to expected, without issuing messages.}, {, (RefLink[VerificationTest, paclet:ref/VerificationTest])[input,expected,messages]
tests whether input evaluates to expected, generating the list of message names messages.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[VerificationTest, paclet:ref/VerificationTest]) returns a (RefLink[TestResultObject, paclet:ref/TestResultObject]).

(RefLink[VerificationTest, paclet:ref/VerificationTest]) has attribute (RefLink[HoldAllComplete, paclet:ref/HoldAllComplete]).

(RefLink[VerificationTest, paclet:ref/VerificationTest]) has the following options:

(RefLink[TestID, paclet:ref/TestID])->(RefLink[Automatic, paclet:ref/Automatic]) creates a unique UUID each time the test is run.

OpenersPrimaryExamplesSection(Spacer1)Examples  (17)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Test whether the input evaluates to (RefLink[True, paclet:ref/True]):

VerificationTest[Sin[E]>Cos[E]]

Test whether the input evaluates to the expected output:

VerificationTest[Expand[(1+x)^3],1+3 x+3 (x^2)+(x^3)]

Input evaluates to the expected output but gives messages:

VerificationTest[(1/0),ComplexInfinity]

Add the expected message:

VerificationTest[1/0,ComplexInfinity,{Power::infy}]

OpenersExampleSection1(Spacer1)Scope  (2)

OpenersExampleSubsection0(Spacer1)Basic Uses  (2)

Perform a test and present the results in a (RefLink[Dataset, paclet:ref/Dataset]):

test=VerificationTest[Integrate[x^(-1),{x, 0,1}],(∫_0^1)(1/x)\[DifferentialD]x];
Dataset[test[test["Properties"]]]

Test if the results of an (RefLink[NIntegrate, paclet:ref/NIntegrate]) are numerically equivalent to (RefLink[Integrate, paclet:ref/Integrate]), by using an absolute tolerance:

NIntegrate[Sin[x],{x,0,2}]-Integrate[Sin[x],{x,0,2}]

VerificationTest[Abs[NIntegrate[Sin[x],{x,0,2}]-Integrate[Sin[x],{x,0,2}]]<(10^(-14)),True]

This can also be done by using the (RefLink[SameTest, paclet:ref/SameTest]) option:

VerificationTest[NIntegrate[Sin[x],{x,0,2}],Integrate[Sin[x],{x,0,2}],SameTest->(Abs[#1-#2]≤(10^(-14))&)]

OpenersExampleSection2(Spacer1)Options  (7)

OpenersExampleSubsection1(Spacer1)MemoryConstraint  (1)

Run a test until a memory limit is exceeded:

ByteCount[Range[10^6]]

VerificationTest[ByteCount[Range[10^6]],8000144,MemoryConstraint->(QuantityUnit[8000])]["ActualOutput"]

OpenersExampleSubsection2(Spacer1)SameTest  (4)

Test whether the input is an integer:

VerificationTest[RandomInteger[{1,10}],_Integer,SameTest->MatchQ]

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

VerificationTest[1.,1.+5 (10.^(-13)),SameTest->(Abs[#1-#2]≤(10^(-12))&)]

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

VerificationTest[1.,1.0001,SameTest->(Abs[(#1-#2)/#2]≤(10^(-5))&)]

Test if two expressions are equivalent after simplification:

VerificationTest[((Cos[x])^2)+((Sin[x])^2),1,SameTest->(Simplify[#1]===Simplify[#2]&)]

OpenersExampleSubsection3(Spacer1)TestID  (1)

Add (RefLink[TestID, paclet:ref/TestID]) to a (RefLink[VerificationTest, paclet:ref/VerificationTest]):

VerificationTest[1+1,2,TestID->"myTestID"]

OpenersExampleSubsection4(Spacer1)TimeConstraint  (1)

Terminate the test if it takes more than one second:

Simplify[2Sin[10x+11y+z]Cos[10x+10y+10t]]//AbsoluteTiming

VerificationTest[Simplify[2 Sin[10 x+11 y+z] Cos[10 x+10 y+10 t]],2 Cos[10 (t+x+y)] Sin[10 x+11 y+z],TimeConstraint->(QuantityUnit[1])]["ActualOutput"]

OpenersExampleSection3(Spacer1)Possible Issues  (5)

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

VerificationTest[1+1,3-2]

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

VerificationTest[ComplexInfinity,1/0]

If both actual and expected output encounter a time constraint or memory constraint, the test is reported to have succeeded:

test=VerificationTest[FullSimplify[2Sin[12x+15y]Cos[14x+21y]],Simplify[2Sin[12x+15y]Cos[14x+21y]],TimeConstraint->(QuantityUnit[0.1])]

This is because both the actual and expected output evaluated to a (RefLink[Failure, paclet:ref/Failure]):

test["ActualOutput"]

test["ExpectedOutput"]

%===%%

If (RefLink[SameTest, paclet:ref/SameTest]) does not evaluate to (RefLink[True, paclet:ref/True]) or (RefLink[False, paclet:ref/False]), an outcome of "Error" is reported:

Equal[x,y]

VerificationTest[x,y,SameTest->Equal]

Tests for functions that produce (RefLink[Graphics, paclet:ref/Graphics]) or special typesetting may produce unexpected results:

Interpolation[Range[6]]

VerificationTest[Interpolation[Range[6]],(CopyTag[InterpolatingFunction[]])]

Plot[Sin[x],{x,0,1}]

VerificationTest[Plot[Sin[x],{x,0,1}],]

This is because the input expressions and the output are not (RefLink[SameQ, paclet:ref/SameQ]):

SameQ[Interpolation[Range[6]],(CopyTag[InterpolatingFunction[]])]

SameQ[Plot[Sin[x],{x,0,1}],]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TestReport, paclet:ref/TestReport])  ▪  (RefLink[TestResultObject, paclet:ref/TestResultObject])  ▪  (RefLink[Assert, paclet:ref/Assert])  ▪  (RefLink[Message, paclet:ref/Message])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Using the Testing Framework, paclet:tutorial/UsingTheTestingFramework])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Tuning & Debugging, paclet:guide/TuningAndDebugging])}, {▪(RefLinkPlain[Systematic Testing & Verification, paclet:guide/SystematicTestingAndVerification])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/47-debugging-your-code.html])(WebLink[: Debugging Your Code, https://www.wolfram.com/language/elementary-introduction/47-debugging-your-code.html])}})}})