TestCreate
✖
TestCreate
create a TestObject that is expected to generate the list of message names messages.
Details and Options

- TestCreate returns a TestObject.
- TestCreate has attribute HoldAllComplete, therefore it does not immediately evaluate input or expected.
- Use TestReport or TestEvaluate to run a test created by TestCreate.
- TestCreate has the following options:
-
MemoryConstraint Infinity memory (in bytes) the test is allowed to use MetaInformation < > extra information associated with the test SameTest SameQ function to compare actual and expected output TestID Automatic unique identifier for the test TimeConstraint Infinity time (in seconds) the test is allowed to use - TestIDAutomatic creates a unique ID by doing a hash of the test expression.
Examples
open allclose allBasic Examples (4)Summary of the most common use cases
Create a test that tests whether the input evaluates to True:

https://wolfram.com/xid/0i1mrluya-rk6fir


https://wolfram.com/xid/0i1mrluya-wx1fgn

Test whether the input evaluates to the expected output:

https://wolfram.com/xid/0i1mrluya-etsac

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

https://wolfram.com/xid/0i1mrluya-lo28e0

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

https://wolfram.com/xid/0i1mrluya-hpzn0o


https://wolfram.com/xid/0i1mrluya-lj5alc

Scope (2)Survey of the scope of standard use cases
Basic Uses (2)
Perform a test and present the results in a Dataset:

https://wolfram.com/xid/0i1mrluya-zlgxdz

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

https://wolfram.com/xid/0i1mrluya-m2i7dm


https://wolfram.com/xid/0i1mrluya-ustp54

This can also be done by using the SameTest option:

https://wolfram.com/xid/0i1mrluya-8v0agp

https://wolfram.com/xid/0i1mrluya-8w4cm1

Options (13)Common values & functionality for each option
MemoryConstraint (1)
SameTest (5)
Test whether the input is an integer:

https://wolfram.com/xid/0i1mrluya-bu1n63

https://wolfram.com/xid/0i1mrluya-pm0wkg

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

https://wolfram.com/xid/0i1mrluya-d1t5j9

https://wolfram.com/xid/0i1mrluya-qprc0q

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

https://wolfram.com/xid/0i1mrluya-o5vwtb

https://wolfram.com/xid/0i1mrluya-j96va8

Test if two expressions are equivalent after simplification:

https://wolfram.com/xid/0i1mrluya-wz6o93

Use Unevaluated to pass unevaluated expressions to the SameTest function:

https://wolfram.com/xid/0i1mrluya-o5dvwt

https://wolfram.com/xid/0i1mrluya-bqh8qy

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

https://wolfram.com/xid/0i1mrluya-le6exj

https://wolfram.com/xid/0i1mrluya-o8ac5j


TestID (4)
Add a TestID to the test:

https://wolfram.com/xid/0i1mrluya-mmvbp7

A TestID can be any expression:

https://wolfram.com/xid/0i1mrluya-7ioegy

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

https://wolfram.com/xid/0i1mrluya-f63lqb

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

https://wolfram.com/xid/0i1mrluya-j9n9eu

Use CreateUUID to create random identifiers every time:

https://wolfram.com/xid/0i1mrluya-w8zbvk

TimeConstraint (1)
MetaInformation (2)
Store arbitrary metainformation in the TestObject:

https://wolfram.com/xid/0i1mrluya-ukoq4d

Access the stored MetaInformation:

https://wolfram.com/xid/0i1mrluya-oif5iw

MetaInformation can be any expression:

https://wolfram.com/xid/0i1mrluya-imx9ut


https://wolfram.com/xid/0i1mrluya-kkj6ff

Possible Issues (3)Common pitfalls and unexpected behavior
The expected output is evaluated before comparison with the actual output:

https://wolfram.com/xid/0i1mrluya-s7ucms

https://wolfram.com/xid/0i1mrluya-f8ytgp

Use Unevaluated to compare expressions before evaluation happens:

https://wolfram.com/xid/0i1mrluya-dp6zfq

https://wolfram.com/xid/0i1mrluya-sbxbs2

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

https://wolfram.com/xid/0i1mrluya-ntticc


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

https://wolfram.com/xid/0i1mrluya-qprtig


https://wolfram.com/xid/0i1mrluya-i22y4x

Wolfram Research (2023), TestCreate, Wolfram Language function, https://reference.wolfram.com/language/ref/TestCreate.html.
Text
Wolfram Research (2023), TestCreate, Wolfram Language function, https://reference.wolfram.com/language/ref/TestCreate.html.
Wolfram Research (2023), TestCreate, Wolfram Language function, https://reference.wolfram.com/language/ref/TestCreate.html.
CMS
Wolfram Language. 2023. "TestCreate." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TestCreate.html.
Wolfram Language. 2023. "TestCreate." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TestCreate.html.
APA
Wolfram Language. (2023). TestCreate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TestCreate.html
Wolfram Language. (2023). TestCreate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TestCreate.html
BibTeX
@misc{reference.wolfram_2025_testcreate, author="Wolfram Research", title="{TestCreate}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/TestCreate.html}", note=[Accessed: 07-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_testcreate, organization={Wolfram Research}, title={TestCreate}, year={2023}, url={https://reference.wolfram.com/language/ref/TestCreate.html}, note=[Accessed: 07-June-2025
]}