Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Unit Testing a Day Object in CSIS 110 Appointment Book - Prof. Brian F. Hanks, Study notes of Javascript programming

In this lecture of csis 110, students are introduced to unit testing, specifically testing the day class in an appointment book application. The lecture covers the importance of unit testing, testing methods such as makeappointment and showappointments, and testing boundaries and edge cases. Students are asked to find and report bugs in the day class and submit corrected versions for grading.

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-8wy-1
koofers-user-8wy-1 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSIS 110 - Lecture 33
Announcements:
Read: Chapter 6, sec 6.1 to 6.3.
Quiz Results:
Possible 25
Mean 18.3
Median 20.25
Max 24
Distribution: <15: 2 15-17: 4 17.5-19.5: 0 20-22: 5 22.5-24.5: 3
Testing
Last time we started looking at testing.
- application testing: testing a completed application, often only through its user
interface.
oWe saw that even testing a simple application takes a lot of effort
oConcepts: boundary conditions, positive and negative test cases
oDiscuss next assignment - What do you think is the point of this
assignment?
- Unit testing: testing parts of an application as you write it.
Unit Testing
What's unit testing?
Testing parts of an application while you are building it:
- it's never too early to start testing
- Allows you to find problems earlier, when they are easier to fix
- You build a set of tests, which you can reuse when you modify the code
So, let's try some unit testing. Open up the diary-prototype project from the chapter 6
folder.
This is an early version of an appointment book. The final goal is to build an application
that allows users to schedule appointments up to 1 year in advance.
In this version, there are 3 classes:
- Appointment: objects that keep track of an appointment's purpose and duration
- Day: A Day object keeps track of a set of Appointments that have been made on a
single day. Each day has a unique position in the year – a value from 1 to 366.
Appoints can only be made from 9AM to 5PM (using a 24 hour clock).
pf3
pf4

Partial preview of the text

Download Unit Testing a Day Object in CSIS 110 Appointment Book - Prof. Brian F. Hanks and more Study notes Javascript programming in PDF only on Docsity!

CSIS 110 - Lecture 33

Announcements: Read: Chapter 6, sec 6.1 to 6.3. Quiz Results: Possible 25 Mean 18. Median 20. Max 24 Distribution: <15: 2 15-17: 4 17.5-19.5: 0 20-22: 5 22.5-24.5: 3 Testing Last time we started looking at testing.

  • application testing: testing a completed application, often only through its user interface. o We saw that even testing a simple application takes a lot of effort o Concepts: boundary conditions, positive and negative test cases o Discuss next assignment - What do you think is the point of this assignment?
  • Unit testing: testing parts of an application as you write it. Unit Testing What's unit testing? Testing parts of an application while you are building it:
  • it's never too early to start testing
  • Allows you to find problems earlier, when they are easier to fix
  • You build a set of tests, which you can reuse when you modify the code So, let's try some unit testing. Open up the diary-prototype project from the chapter 6 folder. This is an early version of an appointment book. The final goal is to build an application that allows users to schedule appointments up to 1 year in advance. In this version, there are 3 classes:
  • Appointment: objects that keep track of an appointment's purpose and duration
  • Day: A Day object keeps track of a set of Appointments that have been made on a single day. Each day has a unique position in the year – a value from 1 to 366. Appoints can only be made from 9AM to 5PM (using a 24 hour clock).
  • Week: Keeps track of the days in a week There are 2 simplifications in this project: appointments always start on an hour, and they always last for a multiple of 1 hour. Let's focus on the Day class – how would we go about testing it? What kinds of questions do you have about the behavior of a Day object?
  • Does it have enough room to store the required number of appointments?
  • Doe the showAppointments method correctly display appointments that have been made?
  • Does the makeAppointment method correctly update the appointment field?
  • Does findSpace return the correct answer? We can answer all of these questions using the object bench and object inspectors. Create a Day object. Open the object inspector – does the appointment field have enough elements to store the required number of appointments? Leave the object inspector open. One thing we want to do is make sure that objects behave correctly both when they are empty and when they are full. So, before we create any appointments we should make sure that showAppointments works. Another element of good testing is to check boundaries – this is where mistakes are often made. What are the boundaries of the Day object?
  • the first appt of the day
  • the last appt of the day Try to create 1 hour appointments at the beginning and end of the day. Also create one in the middle of the day. Use the inspector to make sure the appointments were created. Also call the showAppointments method Are there any other boundaries? Is there anything else we should check at the boundaries? Yes- want to make sure that the method works correctly for values just outside of the boundaries – make sure the method behaves correctly when you try to make an appointment at 8 or 18. What else should we try? What about double booking? What should happen if we try to make an appointment at the same time as one that already exists? Try it. Did it work? How do you know?

Lab 26 Do Exercise 6.8 on page 165 of the book. Modify the Day class to fix any bugs that you find. Turn in:

  1. A word processed document describing each bug that you found.
  2. Your corrected version of the Day class. Use the homework submission system to turn in Day.java and your list of bugs. Lab 26 Do Exercise 6.8 on page 165 of the book. Modify the Day class to fix any bugs that you find. Turn in:
  3. A word processed document describing each bug that you found.
  4. Your corrected version of the Day class. Use the homework submission system to turn in Day.java and your list of bugs. Lab 26 Do Exercise 6.8 on page 165 of the book. Modify the Day class to fix any bugs that you find. Turn in:
  5. A word processed document describing each bug that you found.
  6. Your corrected version of the Day class. Use the homework submission system to turn in Day.java and your list of bugs. Lab 26 Do Exercise 6.8 on page 165 of the book. Modify the Day class to fix any bugs that you find. Turn in:
  7. A word processed document describing each bug that you found.
  8. Your corrected version of the Day class. Use the homework submission system to turn in Day.java and your list of bugs.