The goal of this lab is to gain experience writing JUnit tests.
JMU has the following severe weather cancellation policy*.
If any of the following conditions are met, campus will be closed:
If none of the above conditions are met, the University may still issue a warning and encourage individuals to avoid non-essential outdoor activities. A warning will be issued if any of the following conditions are met:
The following Java class has been developed as part of a JMU Decision Support system:
The weatherAdvice
method provides an implementation
of the cancellation policy above. Your job is to develop a set of
JUnit tests to confirm that this method is implemented correctly.
Your testing must also confirm that the correct exception is thrown
when the method receives invalid input. Refer to the Javadoc for
a detailed specification.
You may use the following class as a starting point for your testing:
Once you are confident that your unit tests are sufficient, Upload
both WeatherUtils.java
and WeatherUtilsTest.java
to Web-CAT. The submission tests for this lab are
configured to check the code coverage provided by your tests. Your
goal is to achieve 100% method, statement, and branch coverage.
100% coverage doesn't necessarily mean that your tests are good. High quality tests should be able to uncover errors in the code that is being tested. The next step is to run your tests against an implementation that is known to contain errors. If your tests are effective, they should indicate that there is a problem with this code. For this part of the lab you will run your tests against a pre-compiled .class file that I have intentionally coded to contain at least one error.
WeatherUtilsTest.java
file into
the new project, and make sure that JUnit 4 is on the project build
path.