Creating and Editing Unit Tests
Unit tests are created and edited in Unit Test Modules.
A newly created unit test module contains a single unit test when first opened. To add a new unit test, highlight any unit test and press the Enter key.
To create a unit test:
- Open any Unit Test Module referenced in the Document Explorer or create a new Unit Test Module.
- Highlight an existing unit test and press either the Insert or the Enter key. The Insert key adds a new unit test above the highlighted test, the Enter key adds a new unit test below the highlighted test. If the Unit Test Module is empty, right-click anywhere in the module and select Insert unit test or just press the Enter key.
- Create the expression to be executed on the left side of the new test.
- Create the result expression on the right side of the test. You can also populate the right side of a unit test by running the unit test (F8). The test will fail, but you can copy and paste the actual result into the right side of the test (assuming that you have verified that the result is correct).
When you use Enter or Insert, new unit tests are created containing the UnitTest object ([] → []), but in principal, any expression can be pasted into a unit test. There are cases where the top object may not be a UnitTest. Unit tests that contain Where clauses are one example.
A single unit test can be disabled by right-clicking the unit test and selecting Disable unit test (F9) from the context menu.
Keystroke or mouse event | Action |
---|---|
Shift + Up arrow | Removes the last unit test from the highlight |
Shift + Dn arrow | Adds the next unit test to the highlight |
Shift + Left click | Adds all unit tests between the last highlighted test and the selected test to the highlighted unit tests |
Ctrl + Left click | Adds the selected expression to the current highlight. |
F8 | Runs all of the highlighted unit tests. Tests that are only partially highlighted will also be executed. |
F9 | Toggles the enable/disable setting on all of the highlighted unit tests. |
Enter | When the entire unit test is highlighted, the Enter key will insert a new unit test below the highlighted test. |
Insert | When the entire unit test is highlighted, the Insert key will insert a new unit test above the highlighted test. |
Delete | When the entire unit test is highlighted, the Delete key will remove the unit test from the module. Otherwise, delete will delete the highlighted term in the usual way. |
Ctrl+Delete | When the entire unit test is highlighted, the Ctrl+Delete key will replace the unit test expression with an empty box. |
By default, variables in unit test expressions are treated the same way as variables in clauses.