CS 1054: Lab 9

Lab meeting 9: Well behaved Objects

The purpose of this lab is to introduce you to the process of testing.

Unit testing

  1. Start the BlueJ environment by clicking on Start->Programs->BlueJ.
  2. Make a directory on the Z: drive with your university pid as the name. Download lab9.zip to the Z: drive and unzip it. This should unzip three projects to the Z: drive including diary-prototype, diary-testing and diary-test-automation.
  3. Open the diary-prototype project. You can see three classes in this project including Day, Appointment and Week. You will be examining the Day class and testing it in this lab.
  4. Perform the tasks outlined in Exercises 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7 and 6.8.

Regression testing

  1. Regression testing involves automating testing using separate test rigs or test harnesses.
  2. Open the diary-testing project. Examine the code present in the OneHourTests class. You can see that this is similar to the code that we used in your project 2 that was used to test various methods in your quarterback-rating class. Understand that various methods are being invoked from the Day class to make sure that some testing is done through this class. Using this test harness saves time in having to manually perform the tests.
  3. Do the tasks outlined in Exercises 6.10 and 6.11.

Automated checking of test results

  1. Open the diary-test-automation project. This project does even more automated testing compared to the earlier approach. The approach shown above still involves manually examining the results produced by the testing.
  2. This project uses the &= operator for testing the results produces by a number of method invocations involving various tests.
  3. See if you can make modifications to some method invocations within the makeThreeAppointments() method that would cause the testing to fail. Hint: See Exercises 6.3 and 6.6 to get ideas of how to modify the method invocations.
  4. If you have time, implement the checkResult() method described on Page 154 to see if you can see on what line the test fails.
  5. Show your work to the GTA.

© Mir Farooq Ali 2003.