More Testing and Exam Follow-up

In previous labs, you used the JUnit framework to implement test of individual methods. In this lab you will develop a comprehensive suite of tests for all of the methods in a class that you have implemented.

Materials

Before going any further you should:
  1. Make a directory for this lab.
  2. Download the following files into your lab directory:

1. Getting Ready for Testing

If you have not already done so, finish coding the Document.java class. Each method is described in detail inside of the code. If you have already completed Document.java, copy the equals method into your code. It will be helpful for testing for testing the saveDocument method.

2. Designing Tests

Looking at the Document class, you will need to test 5 methods. For each method, what are the different document types (or lines) that you will need to test the methods properly? For example, tst1.txt (the file provided above) contains 3 lines. There is one empty line and the other two contain words. Think about each method that you will want to test and the different ranges of values that you will want to test. Fill in the TestCases.rtf with tests that you might run. Start with a list of the test input files and which Document object you will build from it in setup. Then as you develop each test, decide which of the objects you will use to test that method thoroughly.

3. Set-Up the Document Objects You Will Use for Testing

Create a JUnit test file for testing Document.java. In the setup method, create Document objects to use for testing as described in Part 2.

4. Build Tests for Each Method

Implement your tests one method at a time. Run your test suite after you have implemented each test.
Acknowledgments: This is a modified version of a lab developed by Nancy Harris.