The Readability guideline
Is this method readable? Do you need to run it and start debugging to understand what it does? Does the Arrange
section make your eyes bleed? This might be violating the readability principle.
Having the Intention guideline established is fabulous, but it is not enough. You will have at least 10x more lines of code in your unit tests compared to your production code. All this needs to be maintained and grow with the rest of your system.
Tidying up the unit test for readability follows the same practices as the production code. However, there are some scenarios that are more dominant in unit tests, which we are going to address here.
SUT constructor initialization
Initializing your SUT will require that you prepare all the dependencies and pass them to the SUT, something like this:
// Arrange const double NEXT_T = 3.3; const double DAY5_T = 7.7; var today = new DateTime(2022, 1, 1); var realWeatherTemps = new[] {2, NEXT_T...