parasoft C++ unit test question

大城市里の小女人 提交于 2019-12-10 10:39:20

问题


I work on a project that was just told we had to incorporate Parasoft C++ unit testing tool into any code changes going forward. The problem I face is that we have methods with very small changes and now it seems we are forced to unit test the whole method. Many of these methods are hundreds or thousands of lines of code. I know for certain that if I have to test the methods entirely then we will run into fixing old issues such as null pointer checks and our budget and manpower can't handle these fixes.

Does anyone know if parasoft allows you to test small portions of a method? or if another unit testing framework would work better.


回答1:


Implement the small change you are making in a new method, test that. Then change the original to call the new method.

You will be testing the change and gotten a little refactor to better code.




回答2:


No unit testing framework allows you to just test portions of a method.

One ugly suggestion is to use #include to include small chunks of code directly into methods, with the same #include used to include that code into a testing method that sets up variables used by that code.

I recommend Michael Feather's book Working Effectively with Legacy Code for advice on how to add testing to a large code base. It's also available online at Safari.



来源:https://stackoverflow.com/questions/281037/parasoft-c-unit-test-question

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!