Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create a palette with tools for creating unit tests
ResourceFunction["OpenTestWritingPalette"][] creates a palette with buttons that allow you to create VerificationTest expressions from pairs of input-output cells. | |
ResourceFunction["OpenTestWritingPalette"][fun] uses fun[] to create a TestID for each test that is created. | |
Open the palette:
| In[1]:= |
| Out[1]= |
The palette has a number of buttons:

The buttons under the heading "Creating tests" all do similar things: they generate tests from input-output cell groups. Evaluate some input to test and then select the CellGroup and press Create tests to create a VerificationTest that can be run immediately:
| In[2]:= |
| Out[2]= |
| In[3]:= | ![]() |
| Out[3]= |
If you use the Browse… button, you can select a plain-text output file to directly append new tests to.
Generated messages will be added to the test as well:
| In[4]:= |
| Out[4]= |
| In[5]:= | ![]() |
| Out[5]= |
You can define your own method for generating a TestID for each test:
| In[6]:= |
| In[7]:= |
| Out[7]= |
| In[8]:= | ![]() |
| Out[8]= |
Use None if you don't want to automatically generate test IDs:
| In[9]:= |
| In[10]:= |
| Out[10]= |
| In[11]:= | ![]() |
| Out[11]= |
You can also convert tests in a testing notebook. Open the example notebook, highlight tests and use the Copy tests button:
| In[12]:= |
| Out[12]= |

Paste them:

Create a TestID generator that automatically increments with each new test:
| In[13]:= | ![]() |
Create some tests:
| In[14]:= |
| Out[14]= |
| In[15]:= |
| Out[15]= |

This work is licensed under a Creative Commons Attribution 4.0 International License