<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to 39: parameterized fixture</title><link href="https://sourceforge.net/p/cppunit/feature-requests/39/" rel="alternate"/><link href="https://sourceforge.net/p/cppunit/feature-requests/39/feed.atom" rel="self"/><id>https://sourceforge.net/p/cppunit/feature-requests/39/</id><updated>2014-02-26T07:49:32.458000Z</updated><subtitle>Recent changes to 39: parameterized fixture</subtitle><entry><title>#39 parameterized fixture</title><link href="https://sourceforge.net/p/cppunit/feature-requests/39/?limit=50#6a75" rel="alternate"/><published>2014-02-26T07:49:32.458000Z</published><updated>2014-02-26T07:49:32.458000Z</updated><author><name>fussel4711</name><uri>https://sourceforge.net/u/userid-1164568/</uri></author><id>https://sourceforge.nete3822a9954f4d66d9dadca1e56b7f1d3f9487dab</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I've implemented some macros aiding to define parameterized CppUnit tests. &lt;/p&gt;
&lt;p&gt;With this solution you just need to replace the old macros CPPUNIT_TEST_SUITE and CPPUNIT_TEST_SUITE_END within the class's header file:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="nx"&gt;CPPUNIT_PARAMETERIZED_TEST_SUITE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;TestSuiteClass&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ParameterType&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cm"&gt;/*&lt;/span&gt;
&lt;span class="cm"&gt; * Put plain old tests here.&lt;/span&gt;
&lt;span class="cm"&gt; */&lt;/span&gt; 
&lt;span class="nx"&gt;CPPUNIT_PARAMETERIZED_TEST_SUITE_END&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the implementation file you need to replace the old CPPUNIT_TEST_SUITE_REGISTRATION macro  with:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="nx"&gt;CPPUNIT_PARAMETERIZED_TEST_SUITE_REGISTRATION&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;TestSuiteClass&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ParameterType&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;These macros require you to implement the methods:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt; &lt;span class="n"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testWithParameter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ParameterType&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;parameter&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;parameters(): Provides a vector with the parameters.&lt;/li&gt;
&lt;li&gt;testWithParameter(...): Is called for each parameter. This is where you implement your parameterized test.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A detailed explanation can be found here: &lt;a href="http://brain-child.de/engineering/parameterizing-cppunit-tests" rel="nofollow"&gt;http://brain-child.de/engineering/parameterizing-cppunit-tests&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The german version can be found here: &lt;a href="http://brain-child.de/engineering/parametrierbare-tests-cppunit" rel="nofollow"&gt;http://brain-child.de/engineering/parametrierbare-tests-cppunit&lt;/a&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I would appreciate if the CppUnit team will integrate my work into the CppUnit framework. In this case it would be nice if you mention the source within the source code and documentation ;)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>parameterized fixture</title><link href="https://sourceforge.net/p/cppunit/feature-requests/39/" rel="alternate"/><published>2004-12-24T09:14:04Z</published><updated>2004-12-24T09:14:04Z</updated><author><name>xaliphostes</name><uri>https://sourceforge.net/u/igeoss/</uri></author><id>https://sourceforge.netd5f732073dabd5fe55e923f1803d3c726797482f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;It would be nice if each test of a fixture can be&lt;br /&gt;
parameterize (with an xml formatting string for example).&lt;/p&gt;
&lt;p&gt;That way, for a same fixture plugin, we can run it&lt;br /&gt;
several times with different parameters.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>