TestObject

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 allclose all

Basic Examples  (2)

Run TestCreate to get a TestObject:

Use TestEvaluate to run the test:

Extract the original input:

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

Scope  (1)

List of all properties:

Extract several properties at once:

Extract all properties and present results in a Dataset:

Applications  (1)

Evaluate a test:

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

Use ReleaseHold to create a new one again:

Properties & Relations  (34)

Properties  (34)

"AbsoluteTime"  (1)

Create a test:

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

Use FromAbsoluteTime to convert the value in a DateObject:

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

"AbsoluteTimeUsed"  (1)

Run a test:

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

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

"ActualMessages"  (1)

Run a test that emits messages:

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

The expression is wrapped in HoldForm:

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

"ActualOutput"  (1)

Run a test:

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

The expression is wrapped in HoldForm:

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

"CPUTimeUsed"  (1)

Run a test:

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

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

"Created"  (1)

Create a test:

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

"ExpectedMessages"  (1)

Create a test:

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

The expression is wrapped in HoldForm:

"ExpectedOutput"  (1)

Create a test:

Use "ExpectedOutput" to extract the expected result:

The expression is wrapped in HoldForm:

"FailureType"  (11)

Evaluate a test:

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

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

The failure type is "SameTestUnevaluated":

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

The failure type is "TimeConstrainedFailure":

Create a test in which the TimeConstraint value is invalid:

The failure type is "TimeConstrainedInvalid":

Create a test in which the MemoryConstraint value is exceeded:

The failure type is "MemoryConstrainedFailure":

Create a test in which the MemoryConstraint value is invalid:

The failure type is "MemoryConstrainedInvalid":

Create a test where an Abort[] is encountered:

The failure type is "AbortFailure":

Create a test where a Throw[] is encountered:

The failure type is "UncaughtThrowFailure":

Create a test where an IntermediateTest fails:

The failure type is "IntermediateTestFailure":

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

The failure type is "IntermediateTestMessagesFailure":

The failure type None is returned when a test succeeds:

"Input"  (1)

Create a test:

Use "Input" to extract the original input expression:

The expression is wrapped in HoldForm:

"MemoryConstraint"  (1)

Create a test that uses the MemoryConstraint option:

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

"MemoryUsed"  (1)

Run a test:

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

"MetaInformation"  (1)

Create a test:

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

"Outcome"  (1)

Run a test:

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

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

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

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

"SameTest"  (1)

Create a test:

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

"TestFileName"  (1)

Run a test suite from a file or notebook:

Extract the first TestObject:

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

"TestID"  (4)

Create a test:

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

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:

"TestKey"  (1)

Create a test:

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

"TestKey" will change after the test evaluates:

"TimeConstraint"  (1)

Create a test:

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

"TestCreate"  (1)

Create a test:

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

The expression is wrapped in HoldForm:

"VerificationTest"  (1)

Create a test:

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

The expression is wrapped in HoldForm:

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_2024_testobject, author="Wolfram Research", title="{TestObject}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/TestObject.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_testobject, organization={Wolfram Research}, title={TestObject}, year={2023}, url={https://reference.wolfram.com/language/ref/TestObject.html}, note=[Accessed: 22-December-2024 ]}