I think I may be writing -too- many unit tests.For example, say I was doing a coursework management system, and I coded a feature for submitting coursework on behalf of a student. If invalid credentials are specified in the API call, a 401 forbidden is returned. If a student tries to submit a different student's coursework, a different error is returned. If a student sends in his own coursework, its accepted but in a 'pending' status, awaiting approval from staff. If a faculty member sends in coursework on behalf of a student, its automatically accepted and also put in 'approved' status automatically.As you can see, there are about 4-5 different scenarios here, each with a different outcome.I tend to write tests for each scenario. That means, it might take me 10-15 mins to code the feature, but then another 15 mins - an hour, to write and pass all the unit tests. May be even 2 hours.Obviously this is making me slow, and I'm expected to deliver results much faster. But unless I write all those tests, it feels 'wrong', and that the code may not work as expected.What's the solution here? What's the right amount of unit tests to write? For every 1 hour of coding, how much time, max, should be spent writing tests for that feature?
Determining the optimal amount of unit tests?
unit testing;agile;tdd;productivity