[Mockpp-commits] mockpp/mockpp/docs/en dev_advanced_intro.docbook,1.5,1.6
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-11-18 21:43:53
|
Update of /cvsroot/mockpp/mockpp/mockpp/docs/en In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32719/mockpp/docs/en Modified Files: dev_advanced_intro.docbook Log Message: update Index: dev_advanced_intro.docbook =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/docs/en/dev_advanced_intro.docbook,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- dev_advanced_intro.docbook 3 Jan 2005 11:10:14 -0000 1.5 +++ dev_advanced_intro.docbook 18 Nov 2005 21:43:45 -0000 1.6 @@ -133,42 +133,68 @@ <para>More detailed explanations follow in later chapters.</para> +</sect3> + +<sect3 id="setup_behaviour"> +<title>How To Set Up Behaviour</title> + <para>The basic principle for the use of these classes is the same for both methods: <itemizedlist> <listitem>Derive from the interface class and the according mock object class.</listitem> <listitem>Add the methods and their internal variables with one of the predefined pair of macros.</listitem> - <listitem>Use one of the according macros to construct a helperobject + <listitem>Use one of the available methods to construct a helper object to set up the detailed behaviour.</listitem> </itemizedlist> </para> -<para> -<warning> - <title>But let me warn you:</title> - <para> - If you take the wrong macro or maybe just have a small typo you will get loads - of error messages all pointing to the same line. You might have no idea where to start - and search the problem. I strongly recommend to take little steps when setting - up such objects: add one single method and compile. - Continue only if it compiled flawlessly. - </para> +There are two standard ways to set up the behaviour of advanced mock objects. - <para>This warning shouldn't scare you away. It isn't really that complicated and - once you have - understood the working method of the macros you may have understood half - of &mockpp;. To get started I recommend to use the "recipies" below.</para> -</warning> +<itemizedlist> + <listitem><para>The traditional way using macros which implement everything behind the + scenes and an additional helper object which controls these helper objects.</para> -<para>If you want to have an overview what is created behind the scenes, look at -<filename>chainable-template.h</filename> and -<filename>visitable-template.h</filename> which contain example classes with some methods. -They were preprocessed, automatically indented and are quite readable. -This knowledge might become useful when you need to find out more about the referenced objects -and their internal helper variables when runtime errors occur.</para> + <para>But caution: if you take the wrong macro or maybe just have a small typo you will get loads + of error messages all pointing to the same line. I strongly recommend to take little steps when setting + up such objects: add one single method and compile. To get started I recommend to + use the "recipies" below.</para> + + <para>If you want to have an overview what is created behind the scenes, look at + <filename>chainable-template.h</filename> and + <filename>visitable-template.h</filename> which contain example classes with some methods. + They were preprocessed, automatically indented and are quite readable. + This knowledge might become useful when you need to find out more about the referenced objects + and their internal helper variables when runtime errors occur.</para> + </listitem> + + <listitem><para>The newer and recommended approach with the help of mock methods. + The methods are templates which wrap the method under test. Since they are fully + accessible in constrast to a macro they are easier to use and better to debug.</para> + + <para>For both the Visitable and the Chainable types there are sets of templates + for mock methods according to the number of parameters the method under test takes. + But most of + the current compilers support a short hand version which selects the needed + template automatically.</para> + + <para>So the following lines are equivalent: + + <programlisting> + + mockpp::VisitableMockMethod0<void> mmv0(MOCKPP_PCHAR("mm0"), 0); + mockpp::VisitableMockMethod1<void, int> mmv1(MOCKPP_PCHAR("mm1"), 0); + mockpp::VisitableMockMethod2<void, int, int> mmv2(MOCKPP_PCHAR("mm2"), 0); + + mockpp::VisitableMockMethod<void> mmvd0(MOCKPP_PCHAR("mm0"), 0); + mockpp::VisitableMockMethod<void, int> mmvd1(MOCKPP_PCHAR("mm1"), 0); + mockpp::VisitableMockMethod<void, int, int> mmvd2(MOCKPP_PCHAR("mm2"), 0); + </programlisting> + + </para> + </listitem> +</itemizedlist> -</para> </sect3> <sect3 id="choosing_macro"> |