Save a repeatable script test
PCA 3D ADVENTURE STUDIO PCA Script programming
STUDIO 0.86.4.6 • LESSON 4 OF 4
Turn a known result into a test you can run after changing a script, function signature or caller.
1. Start from a known answer
Open Clock-and-Debugging.pca3d and choose Debug & Profile → Regression tests. Choose Run all. The three supplied calculations return 60. Select one. Check its Language, Script and Function. Arguments is a JSON array, so a function taking no parameters uses [].
2. Build a case of your own
Choose New and give it a descriptive name. Select language, script and function. Enter starting globals as a JSON object, for example {"pressure":66}, when your script reads that variable. Put only the globals you want to check in Expected globals. Tick Check return value if appropriate and enter the expected result as JSON.
3. Prove that it can fail
Record expectations can populate a draft from a real run. Compare each value with your intended outcome. Save test and save the project. In a copy of a supplied case, deliberately change the expected return from 60 to 61, save it, then choose Run selected. Read the mismatch, restore 60 and rerun.
The workbench test specifies the script, entry, JSON inputs and expected return before it runs.
WHAT TO CHECK
The copied case should fail at 61 and pass at 60. If both runs pass, check the selected case and Check return value. A passing isolated script test is useful alongside a play-through that actually triggers its GUI or dialogue caller.
Related original lesson | p. 47 Tutorial edition 0.86.4.7
