No joke, I've seen tests that have had if statements in them, it makes me cringe! How do you then know if the test does not have bugs when you add conditionals and branches 🙈
Great tips, Helen! Having multiple execution paths in a tests is a bad sign. It is important to keep tests small and if needed use parametrized tests.
To write better unit tests, you should start by writing testable code and have a clear testing strategy. Test early and often.
Make sure your tests are simple and focused, each test should cover one aspect of the code functionality. Avoid writing overly large or overly trivial tests.
No joke, I've seen tests that have had if statements in them, it makes me cringe! How do you then know if the test does not have bugs when you add conditionals and branches 🙈
Great article, thanks for sharing!
Great tips, Helen! Having multiple execution paths in a tests is a bad sign. It is important to keep tests small and if needed use parametrized tests.
To write better unit tests, you should start by writing testable code and have a clear testing strategy. Test early and often.
Make sure your tests are simple and focused, each test should cover one aspect of the code functionality. Avoid writing overly large or overly trivial tests.
Also as a rule of thumb, you should aim to leave the code coverage a little better than how you found it.