Reputation: 4107
I have a moderately to highly complicated application that is backed by a large database of about 50-60 tables. I'm trying to get as much unit test coverage as possible on the code, but I am really struggling with mocking a dataset and some key concepts. I actually have anxiety at the thought of trying to implement full unit test coverage because I'm not sure how to do the following:
1)Test every possible scenario and data combination for each function. I.E. One of our functions returns a value based upon about 20 inputs with 3 different possible values for each input. How could one possibly test all of the values for something like that? And if I could test all those combinations, I would have to write the exact same logical code in the test to determine if it should have passed or not (isn't this redundant?).
2) Data and results change with time! For example, if I run a query for the number of employees who rented a car in the last week, I will always be returning a different result as time moves forward. How can I write a unit test that knows how many results to expect if the results will vary from one day to the next?
People say that if you are struggling with unit testing that you are doing it wrong, so please enlighten me on how to best handle these situations.
Upvotes: 1
Views: 193
Reputation: 122042
My comment above notwithstanding, here are some thoughts:
Upvotes: 1