[Declaration] If you need to copy, spread, please attach this statement, thank you. Original source: http://morningspace.51.net/ ,moyingzz@etang.com
Preface
This series of articles are selected from the "CPPUnit source code interpretation". CPPUnit is a unit test framework for Open Source implemented with C languages, and one of the XUnit series is transplanted from JUnit.
[introduction]
How to integrate many technologies into an actual Framework, I think that CPPUnit provides us with a difficult-friendly reference example. This should be a good example because it is not very complicated, but has gathered some of the design ideas necessary for Framework and implementation skills. Here, we can see STL's flexible use (including some simple Traits techniques), Design Pattern's comprehensive use (such as Composite, Factory, Decorator, Singleton, Observer, etc.).
Of course, it should also be pointed out that since CPPUnit is still in constant improvement, there is no "failure" in its code and is not satisfactory. However, there is no hossing, and we can also feel the evolution process of a mature framework.
Because of a point of Framework's design experience and experience, the author often has resonance during reading the CPPUnit source code, and the designer of the frame is also very deep, and occasionally "heroes Slightly lane. I hope that you can pass the author's explanation, you can also have the same feelings.
[Simple life of CPPUnit]
CPPUnit is a C implementation version in the XUnit family, which is transplanted from JUnit. The first graft version is complete by Michael Feathers, and the information can be found at http://www.xprogramming.com/software.htm. It is the operating system related, then Jerome Lacoste will transplant it to UNIX / Solaris, which can also be found in the above connections. The CPPUnit project is based on these versions. Discussions on CPPUnit can be found at http://c2.com/cgi/wiki?cppunit, where you can also find CPPUnit's previous version and a portable version in many other operating system environments. This library is protected by GNU LGPL (Lesser General Public License). The author includes: Eric Sommerlade (Sommerlade@gmx.net), Michael Feathers (MFEATHERS@Objectmentor.com), Jerome Lacoste (Lacostej@altern.org), J.E. Hoffmann
, Baptiste Lepilleur
, Bastiaan Bakker
Steve Robbins
The CPPUnit version 1.8.0 is selected here, you can download from http://sourceforge.net/projects/cppunit/ to the latest version.
[CPPUnit's overall composition]
As a complete CPPUnit Framework, although the actual path where the source code is located may not be related, it is logically speaking to the following sections:
CORE: CPPUNIT Output: Output: Output Helper: Some Assistance Extensions: As an extension of unit test, expansion of the CPPUnit Core section (such as: General Test, Repeated Test) listener: Monitor test process and test results Textui: one The text environment for running unit test Portability: Provides all of the above contents to the CPPUnit name space for different platforms.
[Some explanation]
The main content of this paper is based on the CPPUnit source code. Some of the content also come from the comment attached to the source, Changelog et al. Only give the source code interpretation. As for the related background and basic knowledge of the XUnit family, the reader can see related articles for the related articles Relevant knowledge related to Design Pattern, Refactoring, STL, please see the relevant information. In addition to the article itself, the source code listed in the article, there is also some annotations of Morning to further illustrate the code intent, and the interpretation of the Chinese parentheses is Morning in order to save space, simplify the content, highlight the theme, and there is no listing in the article. It is a choice to give some code because of the work, the article writes this series of articles is carried out, so the text is considered, the front and rear consistency of the text is not very tested, please forgive me here.