Contents
How much time should I spend on unit tests?
Typical time budgeted on writing unit tests is about 1 day for every feature that takes 3-4 days of heads down coding. But that can vary with a lot of factors. 99% code coverage is great. Unit tests are great.
What is good unit testing?
A good unit test tells a story about some behavioral aspect of our application, so it should be easy to understand which scenario is being tested and — if the test fails — easy to detect how to address the problem. With a good unit test, we can fix a bug without actually debugging the code!
Is there such thing as too many unit tests?
Yes, it is possible to have too many unit tests – a simple thought experiment shows that you can continue adding tests that don’t provide additional value, and that all those added tests can inhibit at least some refactorings.
How long does writing unit tests take?
In order to do an accurate accounting of how much time you spend on tests you need to write the code without the test. If it really took you three hours to write the test and one to write code for it to pass, you may find that it takes 5+ hours to fix the same bug without writing tests.
Do you know how to do unit testing?
That would improve things over creating a project for each test, but only pain waits down that road (more than a decade ago, I used to test this way, before ubiquitous test runners existed). Adding a method and call for each test will prove laborious, and tracking the output will prove unwieldy.
Is there such a thing as too many unit tests?
If you have worked on large code bases created using Test Driven Development, you would already know there can be such a thing as too many unit tests.
How long is too long for an individual unit test?
One of the most important rules about unit tests is they should run fast. How long is too long for an individual unit test? Developers should be able to run the whole suite of unit tests in seconds, and definitely not in minutes and minutes. Developers should be able to quickly run them after changing the code in anyway.
How many unit tests should be written in a project?
Writing tests for your code will naturally decouple your code, because it would be more difficult to test otherwise. Fast. It is not uncommon for mature projects to have thousands of unit tests. Unit tests should take very little time to run. Milliseconds. Isolated.