Unit Testing
- Why we should UT?
- Unit testable code
- Steps of UT
- What happens if we don’t write unit tests, or UT coverage is less
I worked on a product that is live and working great. I know that the standard development process involves writing UT but I did not do it. Should I have written it? Today, when I did some modifications in one the feature and releases i found that it has caused other users facing problems. Now, I am thinking if i could have written some UT for it it could have helped me to identify this regresssion before release.
Writing unit testing is not post code development process though the code should be written in unit testable format. <how to write unit testable code>
There are certain steps to follow to write a good unit test coverage.
1. Identify all the possible code path — <How will you identify all the paths>
2. Write UT for every possible code path
3. Documentation for reports
Today, I have around 95% of code coverage for the same product and i can feel the difference when i release new features for it. It is really helpful to identify potential regressions and code conflicts in prior. Will you write a unit testable code?
Vikram Singh Chouhan