Wolfram Research

Function Repository Resource:

GenerateVerificationTests (1.0.0) current version: 1.0.1 »

Source Notebook

Generate a VerificationTest file for all permutations of arguments

Contributed by: Jon McLoone

ResourceFunction["GenerateVerificationTests"][file,function,parameters]

generates a file of VerificationTest objects for function of all permutations of parameters.

ResourceFunction["GenerateVerificationTests"][file,function,parameters,prefix]

generates test objects with TestID prefixed with prefix.

Details and Options

The function being tested may have the head Function or Symbol (e.g. Plus).
The tests generated assume that the function is currently behaving correctly and so are only useful for regression testing in future changes to the function.

Examples

Basic Examples (2) 

Generate 27 tests for Plus of three arguments, assuming that Plus is currently behaving correctly:

In[1]:=
ResourceFunction["GenerateVerificationTests", ResourceVersion->"1.0.0"]["example.wlt", Plus, {{6, 2, 3}, {4, 5, 6}, {a, b, c}}]
Out[1]=
In[2]:=
FilePrint["example.wlt", 5]

Generate a TestReport using the file as input:

In[3]:=
TestReport["example.wlt"]
Out[3]=

Scope (1) 

VerificationTest objects generated will list messages generated:

In[4]:=
Quiet[ResourceFunction["GenerateVerificationTests"]["test.wlt", Plus[#1, 1/#2] &, {{1, 2}, {3, 0}}]]
Out[4]=
In[5]:=
FilePrint["test.wlt"]
In[6]:=
TestReport["test.wlt"]
Out[6]=

Options (2) 

All options for VerificationTest are supported:

In[7]:=
FilePrint@
 ResourceFunction["GenerateVerificationTests"]["test.wlt", Plus, {{1, 2}, {3, 0}}, MemoryConstraint -> 1000]

If a TestID is provided, this will be used as a prefix for a unique TestID for each individual test:

In[8]:=
FilePrint@
 ResourceFunction["GenerateVerificationTests"]["test.wlt", Plus, {{1, 2}, {3, 0}}, TestID -> "Plus-"]

Publisher

Jon McLoone

Version History

  • 1.0.1 – 24 February 2023
  • 1.0.0 – 11 October 2021

License Information