- Move your editor cursor (not the mouse) over a class name and hit
alt + Enter(Option + Enterfor Mac?) - Choose "Create Test"
- For "Testing Library", choose "JUnit4" from the dropdown
- You will see an error that says "JUnit4 library not found in the module".
- Click "Fix" and select the option to
Copy 'JUnit' library files toand leave the default path as-is. This copies the necessary stuff we need in order to run unit tests.
- Tests are expressed in a specific way in the code so that JUnit can find them:
- Must be a
public voidmethod - Must have an
@Testattribute
- Must be a
SingleDayForecastis a simple class that keeps track of the high/low temps for the day, the percent chance of rain (as anintbetween 0 and 100), and the outlook for the day (e.g. "Sunny", "Partly Cloudy", etc.). It does not contain additional logic other than getting/setting the values of each property.MultiDayForecastkeeps track of the single-day forecasts for an arbitrary number of days in the future (as anArrayList. It also has a threshold for recommending a rain jacket; if the percent chance of rain on a particular day is greater than or equal to the threshold, it should recommend to the user that they wear a rain jacket on that day.
Carcontains various components of the car, including its engine and safety system.Enginecan be used to start and stop the car, fill the gas tank, and drive.SafetySystemkeeps track of the all the safety features of the car.Airbagkeeps track of an airbag in the car and whether it has been deployed.TirePressureSensorkeeps track of the pressure for a single tire on the car, and whether the current pressure is within the safe range.