COMP1400 – Programming for Designers

Class announcements for Programming for Designers

COMP1400 – Programming for Designers random header image

Tutorial 9

Posted by on September 15th, 2011 · Lab

JUnit Testing

For the exercises this week, download the diary-testing-junit-v2 project. These examples and exercises are based on chapter 6 of the textbook.

  1. Using the diary-testing-junit-v2 project, create a method in DayTest to check that findSpace returns the value of 10 for a one-hour appointment if a day already has a single one-hour appointment at 9 a.m. You must first create the 9 a.m. appointment, then the 10 a.m appointment. Specify assertions for the results of both calls.
  2. Create a test to check that findSpace returns a value of -1 if an attempt is made to find an appointment In a day that is already full.
  3. Create a test class that has Appointment as its reference class. Record separate test methods within It that check that the description and duration flelds of an Appointment object are initialised correctly following its creation.
  4. Create the following negative test in the DayTest class. Create a Day object, a one-hour Appointment object and a two-hour Appointment object. Make the one-hour appointment at 10 a.m. and then try to make the two-hour appointment at 9 a.m. Since this call to makeAppointment should fail, the value to put into the assertion is false. Now run the test. What is shown in the test results window?

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.