Module 1, Part 7

Specifications, Testing, and Debugging

Part 7 is about testing. But before one can test, one has to know what
to test for —one has to know what a method or class to be tested
is supposed to do. So, we discuss briefly the specifications of methods,
fields of a class, and the class itself.

Since you have programmed before, you will know much of what we say here
already, but a review won't hurt, especially of a topic as important as
testing and debugging. Also, the use of a JUnit tester will probably
be new to you.

2. Assertions in Programs

Comments:
An assertion is a true-false statement about the program variables
that is placed somewhere in a program. By placing it in before
or after a statement, one asserts that the assertion is
true at that point.

4. Testing.

Comments:
Testing is the process of running a program against "test cases"
in order to get some evidence of the program's correctness. If a test case
reveals an error, debugging (see points 6–7 below) takes place to
find and correct the error.