Most companies I've worked with don't just focus on adding unit test to existing code, but they also will need to add new functionality to the product.
Therefore, usually I recommend to add the unit tests to the parts of the code where the new functionality is going to be added. That cleans that part up and makes it easier and safer to add new features.
In the end, the purpose of unit testing is *not* testing...
Bas
James
> Thanks all.
> Can I understand like that?
> 1. Don't add UT to leagacy code JUST because you want to add UT. No
> code change, no UT.
Yah, and another exception is when you are doing it mainly for learning perspective. This sometimes happens in a coaching environment
> 2. If you have some code change, such as refactor existing code, or
> new feature, or bug fix, we can select some relative leagacy code to
> add UT to make sure the functions still work after code change.
Yup.
Bas
Sure... but ... it is existing code and has already been used and tested, or?
Bas
Well, if you find it useful, you can do it still :)
As I think I mentioned earlier, usually unit testing is not really for finding defects, but for preventing them :) But, if you find bugs in this way, go ahead :)
Bas
Hi, Terry
Thank you so much for your advice. I'm very interested in your script.
It'll be wonderful if you can share it:)
thanks
Xiaohong Liu