Lab 7: JUnit Testing

Overview

Having thorough tests can ensure the behavior of a class matches its specification, but writing thorough tests can be challenging. In this assignment you will gain experience writing unit tests for an AutoCompleter interface and use it to test your own implementation of the interface.

Video introduction for the lab

Commit 1 - AutoCompleter Comments

Due end of class Tuesday Week 7

AutoCompleter interface

The AutoCompleter interface has the following methods:

You must implement the static format() method and write complete javadocs for all the methods in AutoCompleter.

For this commit, rename the package and write JavaDoc comments for all methods of the interface.

Commit 2 - AutoCompleter Comments

Due end of class Tuesday Week 7

Implement the AutoCompleter.fortmat() method.

Commit 3 - UnorderedList partial implementation

Due end of class Wednesday Week 7

Unordered List Implementation

You must create a class, UnorderedList, that implements the AutoCompleter interface using an unordered list. Your class must have only one private attribute: private final List<String> items that is assigned via a one-argument constructor. Note: the constructor should ensure that no duplicates are in the list passed to the constructor.

For this commit, you must create method stubs for all of the methods and implement the getBackingClass() method.

Commit 4 - getBackingClass() tests

Due end of class Wednesday Week 7

Testing

You must create JUnit tests for all of the methods in the AutoCompleter interface. These tests should be rigorous and ensure all methods behave as specified in the requirements. If the behavior of specific methods are not completely specified, please ask your instructor for clarification.

Use the tests to ensure your UnorderedList implementation conforms to the requirements.

Your instructor may verify your tests by providing multiple faulty implementations to see if your tests catch the errors embedded in the faulty implementations.

Determine and implement the appropriate methods to test the getBackingClass() method.

Commit 5 - UnorderedList add() and size() implementations

Due end of class Thursday Week 7

Implement the constructor, UnorderedList.add() and UnorderedList.size() methods.

To ensure there are no duplicates, you can make use of a HashSet. If you have a list called list you can do the following to remove duplicates:
Set<String> unique = new HashSet<>(list);
list.clear();
list.addAll(unique);

Commit 6 - Additional tests

Due end of class Monday Week 8

Implement the UnorderedList.add() and UnorderedList.size() methods.

Commit 7 - Lab completed

Due end of class Monday Week 8

Acknowledgement

This laboratory assignment, developed by Dr. Chris Taylor.

See your professor's instructions for details on submission guidelines and due dates.