Q2. How extensive does testing have to be minimum vs maximum range?
E.g. Case: I have a form which captures 20 input fields - do we need assertions for each field to be checked using assertDatabaseHas or doing just count checks on the table are enough? Also for an update method similarly, should we check that each of the 20 fields are updated or only test with one field?
I know ideal situation is to have tests for everything, and I know that this is a very subjective question- that's why I would like to know the range and opinion from senior devs out there.
Apologies for being such a Noob in advance - just starting with the whole TDD theme and I do see the advantages in the long run.
I like to separate tests from the controllers in the Feature folder and the models in the Unit folder.
Basically every line or command in my code developed by me, has to be tested. Its my 100% sure that the code will work everytime I change something.
But what if you pick up a legacy project which doesn't have tests/has very few tests? Do you go back and add them as you develop it or add all of them?
Well that depends of what the project manager decides. How much time do you have to finish the project? How many extra features you need left to finish it? Will this project be finished at all?
If I have the full control of the decisions and a lot of time to spare, I will for sure implement tests in everything. If I find myself in a tight schedule than I won't bother to make a test at all.