Test case (source code)

= Test case

A <test case> specifies conditions, <inputs>, an operation to perform and the expected result or acceptance property for <software testing>. Its <test oracle> must distinguish success from failure.<unittest — Unit testing framework in the Python 3.14 documentation>[opening concepts, test case and test fixture; Basic example, result assertions]{ref} Merely executing a <computer program> without checking an outcome supplies weaker evidence.

For example, a <sorting algorithm> given `3,1,3` should return `1,3,3`. A stronger <test oracle> checks both <sortedness> and preservation of the input <multiset>; checking only <sortedness> would accept an empty result. The <test case> also needs a policy for equal elements if their original order matters. Explicit preconditions and expected outcomes make a failure reproducible and help a later reader understand which contract the <test case> exercises.