$24
• Practice developing effective unit tests
• Practice implementing unit tests with JUnit
• Practice working with TDD Preparation:
Problem Statement
You have three main tasks in this assignment:
• Create a set of unit tests using for the provided classes which are already developed
• The correctness of the code using your unit tests and if you find any bug fix it.
• Use TDD to design unit tests and develop the parts of code that are missing, use the specification on the comments to do this.
Background
You have inherited some buggy and incomplete code for computing shortest path solutions to the board game Ticket to Ride. The previous developer left the company, so it is your job to finish the software. Your boss has hired you to write a comprehensive set of tests for part of the codebase.
Given a game board of rail segments and a list of routes (pairs of cities), the code is supposed to compute the total cost of building a network between the given routes, assuming that the shortest distance for each route is chosen. This can be computed by computing shortest paths for each route using Dijkstra’s shortest path algorithm.
You will be provided with a partial codebase for distance computation, a specification, some JUnit5 test class, and a list of classes for which you are to create unit tests. Your job is to create the test suite, identify and fix the bugs (if any) and finish the methods not implemented in the classes.
Note that the code you are provided does not have a main method and does not have the method implementing Dijkstra’s shortest path algorithm. These will be provided in a later assignments. You only need to write unit tests and finish up the classes already started, not code for the Ticket to Ride problem in this assignment.
Task
1. Read the specification of what the code is supposed to do in docs/specification.pdf
2. Create a set of unit tests using JUnit5 using the provided classes. Remember that each class needs to have its own test class, with several tests to check the implemented methods.
• City.java
• Link.java
• CityComparator.java
3. Implement a separate test class for each of the above target classes. Some sample empty tests and real tests have been provided. For each test class
a. Create as many tests for each method of each class as needed. But remember, each method must have at least one unit test.
b. Each test should provide an appropriate message if it fails.
c. Use good formatting and documentation in your tests, just like for any source code.
4. All the test classes should compile and be runnable in IntelliJ. If your test classes do not compile, you will receive 0 on the assignment.
5. Record all detected errors in a file called errors.txt in the docs directory. Each error should have the following information:
a. Class name
b. Method name
c. Test name that caught the error
d. Message that the test method generated
This information will be used to assess the number of errors found by your tests. An example is provided.
6. Commit as you go and add a clear message about what you did, e.g., finished creating the unit test for setCity() method, then commit with the message about this part of your work before moving to something else.
7. Push back your work to YOUR remote repository, not to the one that you cloned. Everyone has their own repository to deliver this assignment, e.g.,
Remember to check that all your