WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

TestObject []

gives an object that represents the results of a TestCreate .

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Applications  
Properties & Relations  
Properties  
"AbsoluteTime"  
"AbsoluteTimeUsed"  
"ActualMessages"  
"ActualOutput"  
"CPUTimeUsed"  
"Created"  
"ExpectedMessages"  
"ExpectedOutput"  
"FailureType"  
"Input"  
"MemoryConstraint"  
"MemoryUsed"  
"MetaInformation"  
"Outcome"  
"SameTest"  
"TestFileName"  
"TestID"  
"TestKey"  
"TimeConstraint"  
"TestCreate"  
"VerificationTest"  
See Also
Tech Notes
Related Guides
History
Cite this Page

TestObject []

gives an object that represents the results of a TestCreate .

Details

  • TestObject is typically obtained as a result from TestCreate .
  • TestObject []["prop"] returns the value of "prop" for a given TestObject .
  • TestObject [][{"prop1","prop2",}] returns an association of values corresponding to several properties.
  • TestObject []["Properties"] returns a list of all properties available.
  • Possible properties for TestObject include:
  • "AbsoluteTime" absolute time the test was created, in UTC time zone
    "AbsoluteTimeUsed" absolute number of seconds in real time that have elapsed
    "ActualMessages" messages generated on evaluating input
    "ActualOutput" output generated on evaluating input
    "CPUTimeUsed" CPU time spent on evaluating input
    "Created" DateObject of creation time, in $TimeZone
    "ExpectedMessages" messages passed to the test
    "ExpectedOutput" evaluated expected output
    "Input" original test input
    "MemoryConstraint" original MemoryConstraint value
    "MemoryUsed" number of bytes used to store all data
    "Outcome" outcome on running the TestCreate
    "SameTest" original SameTest function
    "TestFileName" absolute file name of the currently executing test file
    "TestID" unique identifier for the test
    "TestKey" automatic key that is unique for every test
    "TimeConstraint" original TimeConstraint value
    "TestCreate" original TestCreate expression
    "VerificationTest" original VerificationTest expression
  • Possible values of the "Outcome" property include:
  • "Success" the test passed successfully
    "MessageFailure" the test failed by emitting messages during the evaluation
    "Failure" the test did not pass successfully
    "NotEvaluated" the test was not evaluated
  • Possible values of the "FailureType" property include:
  • "SameTestFailure" actual output did not match expected output
    "SameMessagesFailure" unexpected messages were emitted
    "SameTestUnevaluated" the SameTest function did not return True or False
    "TimeConstraintFailure" the TimeConstraint option was exceeded
    "MemoryConstraintFailure" the MemoryConstraint option was exceeded
    "TimeConstraintInvalid" the TimeConstraint option was invalid
    "MemoryConstraintInvalid" the MemoryConstraint option was invalid
    "EvaluationAbortedFailure" evaluation was terminated by Abort
    "UncaughtThrowFailure" evaluation was terminated by Throw
    "IntermediateTestFailure" an IntermediateTest failed
    "IntermediateTestMessagesFailure" an IntermediateTest emitted unexpected messages

Examples

open all close all

Basic Examples  (2)

Run TestCreate to get a TestObject :

Wolfram Language code: test = TestCreate[1 + 1, 2]

Use TestEvaluate to run the test:

Wolfram Language code: TestEvaluate[test]

Extract the original input:

Wolfram Language code: test = TestCreate[Integrate[E^-x^2, {x, 0, ∞}], (Sqrt[π]/2)]
Wolfram Language code: test["Input"]

Extract the original input and run the test again by using ReleaseHold :

Wolfram Language code: ReleaseHold @ test["Input"]

Scope  (1)

List of all properties:

Wolfram Language code: test = TestEvaluate @ TestCreate[1 + 1, 2];
Wolfram Language code: test["Properties"]

Extract several properties at once:

Wolfram Language code: test[{"Input", "ExpectedOutput", "Created"}]

Extract all properties and present results in a Dataset :

Wolfram Language code: Dataset[test[All]]

Applications  (1)

Evaluate a test:

Wolfram Language code: test = TestEvaluate @ TestCreate[ 1 + 4, 2, SameTest -> Greater, TestID -> "FiveIsMoreThanTwo" ]

Use the "TestCreate" property to recreate the original test expression:

Wolfram Language code: original = test["TestCreate"]

Use ReleaseHold to create a new one again:

Wolfram Language code: ReleaseHold[original]

Properties & Relations  (34)

Properties  (34)

"AbsoluteTime"  (1)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, 4];

Use "AbsoluteTime" to extract the creation time of the test in UTC:

Wolfram Language code: test["AbsoluteTime"]

Use FromAbsoluteTime to convert the value in a DateObject :

Wolfram Language code: Block[{$TimeZone = "UTC"}, FromAbsoluteTime[test["AbsoluteTime"]]]

Use the "Created" property to get a DateObject in your time zone:

Wolfram Language code: test["Created"]

"AbsoluteTimeUsed"  (1)

Run a test:

Wolfram Language code: test = TestEvaluate[TestCreate[Pause[0.5]]];

Use "AbsoluteTimeUsed" to extract the absolute number of seconds in real time that have elapsed:

Wolfram Language code: test["AbsoluteTimeUsed"]

The property returns a Missing if the TestObject was never evaluated:

Wolfram Language code: TestCreate[2 + 2, 4]["AbsoluteTimeUsed"]

"ActualMessages"  (1)

Run a test that emits messages:

Wolfram Language code: test = TestEvaluate[ TestCreate[ StringJoin[2], Unevaluated[StringJoin[2]] ] ];

Use "ActualMessages" to extract all messages emitted during the evaluation of the test:

Wolfram Language code: test["ActualMessages"]

The expression is wrapped in HoldForm :

Wolfram Language code: test["ActualMessages"]//InputForm

The property returns a Missing if the TestObject was never evaluated:

Wolfram Language code: TestCreate[2 + 2, 4]["ActualMessages"]

"ActualOutput"  (1)

Run a test:

Wolfram Language code: test = TestEvaluate[TestCreate[2 + 2, 4]];

Use "ActualOutput" to extract the result of the input expression:

Wolfram Language code: test["ActualOutput"]

The expression is wrapped in HoldForm :

Wolfram Language code: test["ActualOutput"]//InputForm

The property returns a Missing if the TestObject was never evaluated:

Wolfram Language code: TestCreate[2 + 2, 4]["ActualOutput"]

"CPUTimeUsed"  (1)

Run a test:

Wolfram Language code: test = TestEvaluate[TestCreate[Pause[0.5]]];

Use "CPUTimeUsed" to extract the CPU time spent on evaluating the input:

Wolfram Language code: test["CPUTimeUsed"]

The property returns a Missing if the TestObject was never evaluated:

Wolfram Language code: TestCreate[2 + 2, 4]["CPUTimeUsed"]

"Created"  (1)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, 4];

Use "Created" to extract the creation date as a DateObject :

Wolfram Language code: test["Created"]

"ExpectedMessages"  (1)

Create a test:

Wolfram Language code: test = TestCreate[ StringJoin[2], Unevaluated[StringJoin[2]], StringJoin::string ];

Use "ExpectedMessages" to extract all messages expected during the evaluation of the input:

Wolfram Language code: test["ExpectedMessages"]

The expression is wrapped in HoldForm :

Wolfram Language code: test["ExpectedMessages"]//InputForm

"ExpectedOutput"  (1)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, 4];

Use "ExpectedOutput" to extract the expected result:

Wolfram Language code: test["ExpectedOutput"]

The expression is wrapped in HoldForm :

Wolfram Language code: test["ExpectedOutput"]//InputForm

"FailureType"  (11)

Evaluate a test:

Wolfram Language code: test = TestEvaluate[TestCreate[1, 2]]

Use "FailureType" to extract the failure code for the test:

Wolfram Language code: test["FailureType"]

Create a test for which the SameTest function does not return True or False :

Wolfram Language code: test = TestEvaluate[TestCreate[a, b, SameTest -> Equal]]

The failure type is "SameTestUnevaluated":

Wolfram Language code: test["FailureType"]

Create a test for which the TimeConstraint value will be exceeded:

Wolfram Language code: test = TestEvaluate[TestCreate[Pause[1], Null, TimeConstraint -> 0.2]]

The failure type is "TimeConstrainedFailure":

Wolfram Language code: test["FailureType"]

Create a test in which the TimeConstraint value is invalid:

Wolfram Language code: test = TestEvaluate[TestCreate[Pause[1], Null, TimeConstraint -> someValue]]

The failure type is "TimeConstrainedInvalid":

Wolfram Language code: test["FailureType"]

Create a test in which the MemoryConstraint value is exceeded:

Wolfram Language code: test = TestEvaluate[TestCreate[ConstantArray[1, {2000}], Null, MemoryConstraint -> 100]]

The failure type is "MemoryConstrainedFailure":

Wolfram Language code: test["FailureType"]

Create a test in which the MemoryConstraint value is invalid:

Wolfram Language code: test = TestEvaluate[TestCreate[ConstantArray[1, {2000}], Null, MemoryConstraint -> someValue]]

The failure type is "MemoryConstrainedInvalid":

Wolfram Language code: test["FailureType"]

Create a test where an Abort [] is encountered:

Wolfram Language code: test = TestEvaluate[TestCreate[Abort[]]]

The failure type is "AbortFailure":

Wolfram Language code: test["FailureType"]

Create a test where a Throw [] is encountered:

Wolfram Language code: test = TestEvaluate[TestCreate[Throw[42]]]

The failure type is "UncaughtThrowFailure":

Wolfram Language code: test["FailureType"]

Create a test where an IntermediateTest fails:

Wolfram Language code: test = TestEvaluate[TestCreate[IntermediateTest[1, 2]]]

The failure type is "IntermediateTestFailure":

Wolfram Language code: test["FailureType"]

Create a test where an IntermediateTest fails by emitting unexpected messages:

Wolfram Language code: test = TestEvaluate[ TestCreate[ IntermediateTest[ StringJoin[1, 2], Unevaluated[StringJoin[1, 2]] ] ] ]

The failure type is "IntermediateTestMessagesFailure":

Wolfram Language code: test["FailureType"]

The failure type None is returned when a test succeeds:

Wolfram Language code: test = TestEvaluate[TestCreate[2 + 2, 4]]
Wolfram Language code: test["FailureType"]

"Input"  (1)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, 4];

Use "Input" to extract the original input expression:

Wolfram Language code: test["Input"]

The expression is wrapped in HoldForm :

Wolfram Language code: test["Input"]//InputForm

"MemoryConstraint"  (1)

Create a test that uses the MemoryConstraint option:

Wolfram Language code: test = TestCreate[2 + 2, 4, MemoryConstraint -> 10];

Use "MemoryConstraint" to extract the original value of the option:

Wolfram Language code: test["MemoryConstraint"]

"MemoryUsed"  (1)

Run a test:

Wolfram Language code: test = TestEvaluate[ TestCreate[Range[1000], {___Integer}, SameTest -> MatchQ] ];

Use "MemoryUsed" to extract the memory used during the evaluation of the input:

Wolfram Language code: test["MemoryUsed"]

"MetaInformation"  (1)

Create a test:

Wolfram Language code: test = TestCreate[ 2 + 2, 4, MetaInformation -> <|"MySystemID" -> $SystemID|> ];

Use "MetaInformation" to extract the memory used during the evaluation of the input:

Wolfram Language code: test["MetaInformation"]

"Outcome"  (1)

Run a test:

Wolfram Language code: test = TestEvaluate[TestCreate[2 + 2, 4]];

Use "Outcome" to extract the outcome of a test:

Wolfram Language code: test["Outcome"]

The test will give a "Failure" outcome if the "ActualOutput" does not match the "ExpectedOutput":

Wolfram Language code: TestEvaluate[TestCreate[2 + 2, 5]]

The test will give a "MessagesFailure" outcome if the test succeeds but does not emit the specified list of "ExpectedMessages":

Wolfram Language code: TestEvaluate[TestCreate[StringJoin[2 + 2], Unevaluated[StringJoin[4]]]]

The test will fail if the SameTest function does not return True :

Wolfram Language code: TestEvaluate[TestCreate[a, b, SameTest -> Equal]]

"SameTest"  (1)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, _Integer, SameTest -> MatchQ];

Use "SameTest" to extract the original value of the option:

Wolfram Language code: test["SameTest"]

"TestFileName"  (1)

Run a test suite from a file or notebook:

Wolfram Language code: report = TestReport[FileNameJoin[{"ExampleData", "ExampleTestFile.nb"}]];

Extract the first TestObject :

Wolfram Language code: test = First[report["Results"]]

Use "TestFileName" to extract the name of the test file:

Wolfram Language code: test["TestFileName"]

"TestID"  (4)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, 4, TestID -> "MyTestMultiplication"];

Use "TestID" to extract the original value of the option:

Wolfram Language code: test["TestID"]

A TestID can be any expression:

Wolfram Language code: Table[ VerificationTest[n + 2 > 0, True, TestID -> {"NumericTest", n}], {n, 3} ]

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

Wolfram Language code: TestCreate[2 + 2, 4]["TestID"]

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

Wolfram Language code: TestCreate[2 + 2, 5]["TestID"]

Use CreateUUID to create random identifiers every time:

Wolfram Language code: TestCreate[2 + 2, 5, TestID :> CreateUUID[]]["TestID"]

"TestKey"  (1)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, 4];

Use "TestKey" to extract a globally unique identifier of the test run:

Wolfram Language code: test["TestKey"]

"TestKey" will change after the test evaluates:

Wolfram Language code: TestEvaluate[test]["TestKey"]

"TimeConstraint"  (1)

Create a test:

Wolfram Language code: test = TestCreate[Pause[2], Null, TimeConstraint -> 1];

Use "TimeConstraint" to extract the original value of the option:

Wolfram Language code: test["TimeConstraint"]

"TestCreate"  (1)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, 4];

Use "TestCreate" to create a TestCreate expression from the object:

Wolfram Language code: test["TestCreate"]

The expression is wrapped in HoldForm :

Wolfram Language code: test["TestCreate"]//InputForm

"VerificationTest"  (1)

Create a test:

Wolfram Language code: test = TestCreate[2 + 2, 4];

Use "VerificationTest" to create a VerificationTest expression from the object:

Wolfram Language code: test["VerificationTest"]

The expression is wrapped in HoldForm :

Wolfram Language code: test["VerificationTest"]//InputForm
Wolfram Research (2023), TestObject, Wolfram Language function, https://reference.wolfram.com/language/ref/TestObject.html.

Text

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

CMS

Wolfram Language. 2023. "TestObject." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TestObject.html.

APA

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

BibTeX

@misc{reference.wolfram_2026_testobject, author="Wolfram Research", title="{TestObject}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/TestObject.html}", note=[Accessed: 16-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_testobject, organization={Wolfram Research}, title={TestObject}, year={2023}, url={https://reference.wolfram.com/language/ref/TestObject.html}, note=[Accessed: 16-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /