Algorithms and OOD (CSC 207 2013F) : Labs

Laboratory: Javadoc


Summary: In this laboratory, you will have the chance to improve your skills regarding code documentation and testing.

Exercises

Javadoc

Exercise 0: Preparation

Make sure you’ve read the related reading. It might be useful to refer to it by opening it up in a separate tab.

Exercise 1: Make your own

Now it’s time for you to write some comments and generate Javadocs. In the previous lab you had to fix some broken code. Hopefully you’re done fixing it by now and you know how everything works. Your task for today is to thoroughly document every method and generate the Javadoc HTML. Attach those HTML files to the project and push it to your repository.

* Hint: When you generate Javadoc, the HTML files will automatically be added to your project under the doc (documentation) folder.

Unit Testing

Exercise 2: Setting up

Create a JUnit Test Case for your FixedCode class, by right clicking it going to New > JUnit Test Case. Remember that Eclipse will automatically name the class for you so all you have to do is hit next so that you can move onto the Test Methods screen. When you choose the methods you want to test select sumUp(), removeAs(), convertToFahrenheit(), and powerOf().

Exercise 3: Creating Test Cases

For each test method you must use at least two of the tests provided in the reading, however you must:

  • Utilize an assertEquals test for the methods sumUp(), convertToFahrenheit(), and powerOf().
  • Utilize an assertNotSame test for removeAs()

After you have written your test cases hit run and check to see if all of your methods pass. If any methods fail, make note of which ones and rewrite the test so that they pass. * Hint: This may include utilizing tests like assertTrue or assertFalse.

Copyright (c) 2013 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.