158 ◾ Software Engineering: The Current Practice
In this example, the assert statement is a special statement that is used in the
tools for unit testing; it contains a condition that checks whether the contract for a
particular value is satisfied. e contract for that value is expressed as a logical state-
ment, in this case an equivalence that checks whether a method returns the correct
values. If the condition of the assert statement is not satisfied, the tester is notified
that the test failed. If an assert statement is not available, it can be simulated by
a combination of other statements.
Class TestItem consists of two tests, each testing a different method of class
Item. e method calcSubTotal calculates one line of a customer receipt, ...