Answering frequently asked questions
Now that we have written the unit tests and the associated implementation, let me explain the process.
Are these unit tests enough?
The answer to this question depends on your target coverage and your confidence that all cases are covered. Sometimes, adding more unit tests increases the future maintenance overhead, so with experience, you would strike the right balance.
Why didn’t we unit test the controllers?
The controllers should not contain business logic. We pushed all the logic to the services, then tested the services. What is left in the controllers is minimal code concerned with mapping different types to each other. Have a look at the controllers in Uqs.AppointmentBooking.WebApi/Controllers
to see what I mean.
Unit tests excel in testing business logic or areas where there are conditions and branching. The controllers in the coding style that we chose do not have that.
The controllers should be tested but through...