M/F 2:30-3:20 |
CS 1130: Transition to OO Programming Spring 2016 |
Main
About: Overview Announcements Staff Consultants Calendar Materials: Texts DrJava Terminology Lectures: In-Class Web-Based VideoNote Assessment: Grading Assignments Labs Resources: CMS Piazza (link) Piazza (about) Java API Style Guide Academic Integrity |
Module 1, Part 7Specifications, Testing, and DebuggingPart 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. Contents1. Specifications of MethodsWeb Lecture
Reading:
Lecture Notes
(Lecture Slides) Comments: Each method should have a precise specification, indicating (1) constraints on calls of the method and (2) what the method does. 2. Assertions in Programs
Reading:
Watch all 3 lectures on p. 1-6 of the ProgramLive CD. 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. 3. Javadoc SpecificationsWeb Lecture
Reading:
Lecture Notes Comments: Comments of a certain form, beginning with /**, will be extracted and put on a web page. This allows the user to look at the specs without having to look at the Java program. 4. Testing.
Reading:
Lecture Notes
(Lecture Slides) 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. 5. JUnit TestingWb Lecture
Reading:
Lecture Notes
(Lecture Slides) Comments: DrJava provides a simple means for saving suites of test cases and executing them at will. 6. Debugging (Introduction)
Reading:
Lecture Notes Comments: If an error has been detected, it must be found and removed. This is called debugging. 7. Debugging Demonstration
Reading:
Watch the two lectures on p. 14-4 of the ProgramLive CD Comments: We give some pointers on inserting print statements and demonstrate how to find a bug. |