Reference no: EM133673721
Task: Unit test standards - AAA and FI[R]ST Overview
The 5.1P task asks to improve the Fast property of the [F]IRST principle following the AAA
standards and best practices. There is a fourth test function in WeatherControllerTest.java called testTemperaturePersist() which persists a temperature of a given hour using the controller and matches the persisted timestamp in hh:mm:ss format with the test function's recorded current time. Due to a delay executing the persistence action, there is a difference between persistence time and test function recorded time. This difference violates the Repeatable property of the FI[R]ST principle. You will need to come up with an idea including stopping the clock or fake the clock so that the unit test runs successfully all the time.
Submission details
Use the instructions on the following page to carry out this task's steps.
For this task you will need to study the existing project task5_1P.zip and update the WeatherControllerTest.java file as required.
Submit a pdf combining below items
A screenshot of your Eclipse IDE's (i) JUnit tab which shows test statistics including Runs, Errors and Failures and (ii) Eclipse console which shows outputs.
Your program's source code for tests (WeatherControllerTest.java)
A screenshot of your GitHub page where your latest project folder is pushed.
You want to focus on the following key ideas, and make sure you can explain them in relation to your program.
Keep tests consistent with AAA
FIRST properties of good tests
JUnit's support for AAA.
Instructions
For this task you will need to
Follow instructions like 5.1P task. Download task5_1P.zip Java project and unzip it in a common folder (say, java_projects) which you will be using to store all the weekly projects.
Import the project (as a maven project) in Eclipse IDE.
The test function of interest is testTemperaturePersist() which is currently commented out. Uncomment the function and observe the test behavior. You can comment out the code of other 3 test functions of 5.1P (testTemperatureMin, testTemperatureMax and testTemperatureAverage) and focus only on testTemperaturePersist(). You should keep the student id and name validating test functions.
There are 2 test failures that you need to correct by providing your name and id in the first 2 test cases.
Run the test, take screenshot of test statistic and the console output.
Upload your folder to your GitHub account and take a screenshot.
Your Task
Your task is to:
Study WeatherController.java to understand the member functions of the controller.
Study WeatherControllerTest.java to understand the test function testTemperaturePersist().
This test fails due to a delay in persistence action. Your job will be to restructure the test or the WeatherController class as necessary so that the test runs without error.
Reflect on your strategy for dealing with this scenario.