The PDQForms Debug target contains a Debug menu with commands that are enabled if a PDQDocument is open.
Read test file…
Save test file…
The “Save test file…” command journals edited forms into test files. The “Read test file…” command causes the test file to be read back into the current form, and verifies that values of the calculated fields are correct. This allows for rapid regression testing of forms after making changes to the code base.
I TEST FILE
Test files have the same names as the forms they “exercise,” but with the suffix “test”.
Test files are kept in the same folder as their corresponding “pdq” file.
The test file consists of FIELD_NAME, STRING_VALUE pairs, one pair per line.
II TEST COMMAND
Saving the test file writes out the form’s FIELD_NAME, STRING_VALUE data.
Reading the file back into the current form, populates each FIELD_NAME with its STRING_VALUE and causes that field’s dependents to update.
But if a STRING_VALUE read from the test file begins with an “=”, then it is an expected result and it will be compared to the calculated value of the form’s field, not stuffed into the form.
III TEST RESULTS
The test command logs descrepencies in calculated values:
“Unexpected value for calculated widget: ‘WidgetID’ shown: ‘itsValue’ expected: ‘itsExpectedValue'”
If there are no descrepencies, the test command logs the message:
“All calculated widgets have expected values :-)”
Since the accuracy of calculations in forms is paramount, this simple but powerful approach solves an important problem.