Unit Test C + +

Source: Internet
Author: User

Today, TDD is very hot, my company small, generally write code does not write test, very simple, not regularization. In a traditional structured programming language, such as C, the unit to be tested is usually a function or a sub-process. In an object-oriented language like C + +, the basic unit to be tested is the class.

Unit testing is not only used as an auxiliary means of error-free coding in the one-time development process, unit testing must be repeatable, whether in software modification, or in the process of porting to a new operating environment. Therefore, all tests must be maintained throughout the lifecycle of the software system. Once the coding is complete, developers will always be eager to integrate the software so they can see the actual system starting to work. This appears to be an obvious improvement in appearance, and activities such as unit testing may be seen as an obstacle to the path to this stage, delaying the start of a truly interesting work of linking the entire system.
In this development step, the real progress is replaced by the outward progress. The likelihood that the system will function normally is small, and more cases are filled with various bugs. In practice, such a development step often leads to the result that the software cannot even run. The further result is that a large amount of time will be spent tracking simple bugs that are contained in separate units, and in some cases these bugs may be trivial and trivial, but in general they will lead to additional durations when the software set becomes a system. And when the system is put into use, it is not guaranteed to work reliably.
In practice, the effort to complete the planned unit tests and to write the actual code is roughly the same. Once these unit tests have been completed, many bugs will be corrected and developers will be able to perform more efficient system integration work in the belief that they have a stable and reliable component on hand. This is the real progress, so the unit test under the complete plan is a more efficient use of time. The uncontrolled and sloppy way of working with debuggers only takes more time and has little benefit.

Many of the findings suggest that a complete regression test is needed whenever a change is made, and that testing software products early in the life cycle will ensure the best possible efficiency and quality. The later the bug is discovered, the higher the cost of modifying it, so from an economic point of view, you should find and modify the bug as early as possible. Unit testing is an opportunity to catch a bug early, before the change is too expensive.

Several test frameworks are recommended:

Cpputest, Gooletest,goolemock,cppunit (I heard it was excellent, but didn't try)

References

Http://www.cnblogs.com/wang_yb/p/3999701.html

http://www.ibm.com/developerworks/cn/linux/l-cn-cppunittest/

Http://www.cnblogs.com/cxjchen/archive/2013/05/16/3081118.html

Http://tech.ccidnet.com/art/3737/20060907/894191_1.html

Http://www.cnblogs.com/SelaSelah/archive/2012/04/11/2442525.html

Unit Test C + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.