Explanation
Metamorphic testing explained with a worked example
How can I test a result when I cannot calculate the full expected output?
Metamorphic testing checks an expected relationship between two runs. Transform an input in a controlled way, predict how the output should change or stay the same, and compare the observed relationship with that prediction.
What makes a relationship useful?
The relationship needs an independent reason to hold in the product’s domain. Reordering independent items might preserve a total. It might change a result when priority, rounding or position affects the rule. State those preconditions so a failed relationship is interpretable.
What can still go wrong?
Two wrong outputs can satisfy the same relationship. A calculation that always returns zero will preserve a total under reordering. Add a known example or a second relation that would expose that particular failure.
Worked example
Reorder a stocktake
In a stocktake that sums every line independently, reordering the same lines must preserve each item’s total. Adding one more line for three blue mugs must then increase only the blue-mug total by three. Together the checks catch more faults than either comparison alone.
Try it on your pull request
Choose a change in your repository and tell Cue April what should happen. Review the proposed checks before they run.
Try Cue April on your repository