WOLFRAM

TestReport["file"]

gives a report of the results of the tests from a file.

TestReport[{test1,test2,}]

gives a report of the results of the testi.

TestReport[{report1,report2,}]

gives a unified report by merging all test reports reporti.

Details and Options

  • TestReport returns a TestReportObject.
  • TestReport handles both plain text Wolfram Language files and notebooks that use the Testing Notebook framework.
  • TestReport only runs tests with outcome "NotEvaluated", skipping ones that have already been evaluated.
  • TestReport has the following options:
  • HandlerFunctions <||>how to handle events generated
    HandlerFunctionsKeys Automaticwhat parameters to supply to handler functions
    MemoryConstraint Infinitymemory (in bytes) each test is allowed to use
    ProgressReporting $ProgressReportingwhether to report the progress
    SameTest SameQfunction to compare actual and expected outputs
    TestEvaluationFunction TestEvaluatefunction to evaluate created tests
    TimeConstraint Infinitytime (in seconds) each test is allowed to use
  • TestReport[File["file"]] is also supported.
  • During the execution of TestReport, the following events can be generated:
  • "FileStarted"test file started
    "FileCompleted"test file completed
    "ReportStarted"test report started
    "ReportCompleted"test report completed
    "RuntimeFailure"runtime failure encountered
    "TestCreated"test created
    "TestEvaluated"test evaluated
  • With the specification HandlerFunctions-><|,"eventi"->fi,|>, fi[assoc] is evaluated whenever eventi is generated. The elements of assoc have keys specified by the setting for HandlerFunctionsKeys.
  • Possible keys specified by HandlerFunctionsKeys include:
  • "EventName"name of the event being handled
    "EventID"unique ID of the event
    "Failure"failure object associated with the event
    "FailureType"failure type associated with the test
    "Outcome"outcome associated with the test
    "TestFileName"test file name associated with the event
    "TestObject"test object associated with the event
    "Title"name of the test report
  • TestReport sets $TestFileName to the name of the file from which a test is being run.
  • CreateNotebook["Testing"] opens a blank notebook set up to use the Testing Notebook framework.

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Run a list of TestObject:

Out[1]=1

Run tests from a notebook:

Out[1]=1

Extract information on tests that failed and present it in a TabView:

Out[2]=2

Merge the existing TestReportObject with a new one:

Out[3]=3

Scope  (1)Survey of the scope of standard use cases

Basic Uses  (1)

Run a list of tests:

Out[1]=1

Properties of the TestReportObject:

Out[2]=2

List of individual test results:

Out[3]=3

Compare the expected and actual outputs of tests where those differed:

Out[4]=4

Options  (10)Common values & functionality for each option

HandlerFunctions  (1)

Use HandlerFunctions to log test events happening during the execution of TestReport:

Out[1]=1

Use the special key "UnhandledEvent" to log all events:

Out[2]=2
Out[3]=3

HandlerFunctionsKeys  (1)

Use HandlerFunctionsKeys to select only the keys you are interested in when using HandlerFunctions:

Out[1]=1

If a certain event cannot provide the key you are requesting, it will not be present in the Association:

Out[2]=2

MemoryConstraint  (2)

Apply a memory constraint to each test:

Out[1]=1
Out[2]=2
Out[3]=3

Options for a specific TestCreate override the options set at the TestReport level:

Out[1]=1

ProgressReporting  (1)

Long test runs will automatically display a progress report:

Out[1]=1

Use the option ProgressReporting to disable it:

Out[2]=2

In order to disable the progress reporting globally, you can simply override $ProgressReporting:

Out[3]=3

SameTest  (2)

Apply SameTest to all given tests:

Out[1]=1
Out[2]=2

Options for a specific TestCreate override the options set at the TestReport level:

Out[1]=1

TestEvaluationFunction  (1)

Print all tests in the notebook without evaluating them:

Out[1]=1

Print all tests in the notebook before evaluation and then evaluate them:

Out[2]=2

TimeConstraint  (2)

Apply a time constraint to all given tests:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Options for a specific TestCreate override the options set at the TestReport level:

Out[1]=1

Applications  (1)Sample problems that can be solved with this function

Run a list of individual tests and test files at the same time:

Out[1]=1

Use TestReport again to merge an existing TestReportObject into a new one:

Out[2]=2

When merging multiple TestReportObject instances using TestReport, duplicated tests will be automatically deleted from the report:

Out[3]=3
Out[4]=4
Out[5]=5

Use the property "ResultsByTestFileName" to group together tests from the same file:

Out[6]=6

Properties & Relations  (2)Properties of the function, and connections to other functions

Use Throw and Catch in HandlerFunctions to stop the execution of the test run when a test fails:

Out[1]=1

You can also use Throw and Catch in TestEvaluationFunction:

Out[2]=2

Use Reap and Sow in HandlerFunctions to collect all event names:

Out[1]=1

Possible Issues  (2)Common pitfalls and unexpected behavior

A TestReport with no tests is considered a success:

Out[1]=1
Out[2]=2

TestReport will execute and collect unique tests once:

Out[1]=1

In order to execute the same test multiple times, the test needs to be created multiple times:

Out[2]=2
Wolfram Research (2014), TestReport, Wolfram Language function, https://reference.wolfram.com/language/ref/TestReport.html (updated 2023).
Wolfram Research (2014), TestReport, Wolfram Language function, https://reference.wolfram.com/language/ref/TestReport.html (updated 2023).

Text

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

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

CMS

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

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

APA

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

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

BibTeX

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

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

BibLaTeX

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

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