Test API totals, discounts and calculations
A total can have the correct JSON type and still be wrong. To test a calculation, you need an independent expected expression and an explicit comparison.
The example sums item amounts, stores the expected total in a variable and compares it with the returned total.

Define the expected formula
Start with a small example whose result you can calculate manually. Decide which items participate, whether a discount is a percentage or an amount, and how rounding should work. The test should follow the agreed rule rather than duplicate a possibly incorrect response value.
Save the calculated result
Use Calculate variable for a supported expression, such as sum("$.items[*].amount"), and save it as expectedTotal. Add a JSON field check that compares the returned total with %expectedTotal%. Use the expression help to check the supported functions and syntax.
Test a wrong result and a boundary
Change the returned total while keeping the source item values unchanged. The comparison should fail. Add separate examples for zero items, boundary discounts or rounding when those cases are part of your contract. An undefined rounding rule needs clarification rather than a guessed expected value.
Repeat the check with ready-made files
Download the Checkcraft test case and two inputs. One input is valid, and the other contains a deliberate error. These synthetic examples are available without registration.
Run the example in Checkcraft
Create a collection, a check and a test case using the workspace tree context menu. Click Import in the test case editor and choose the downloaded test case. Open the added case, copy the valid JSON, click Paste data for analysis, then Run test case. Open Result to inspect the report.
Repeat with the broken JSON without changing the rules. The first run should pass and the second should fail. If you see a different outcome, check the selected data source, imported steps and report.
The example files were executed against the application source on 14 September 2026. Reference reports recorded in Russian are available for the passing run and failing run. Sample names and literal data values do not change when you switch the interface language.
See the result on a small example first
Start with the sample, inspect the failure and then try a sanitized example from your own API. Free (beta) is available for Windows and Linux with no time limit.
Get Free (beta)Download and first runAn account and verified email are required to obtain the build. See the edition limits.