<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://morison.biz/technotes/feeds/rss.css" ?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/" 
	xmlns:dc="http://purl.org/dc/elements/1.1/" 
	xmlns:icbm="http://postneo.com/icbm/" 
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/" 
	xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" 
	xmlns:wfw="http://wellformedweb.org/CommentAPI/" >

<channel>
	<title>Comments for: CxxTest setup for the Visual Studio IDE</title>
	<link>http://morison.biz/technotes/articles/23</link>
	<description>The CxxTest docs give a cumbersome, multi-project-with-makefile procedure for using CxxTest in Visual Studio. Here's something better

The CxxTest User Guide suggests one way of intergrating CxxTests with the visual studio IDE involving multiple projects per test suite. This article covers an alternative, single project approach.

The setup was done with Visual Studio 2005 Express. Your mileage may vary on other versions.

 Create a new win32 console project, e.g., TestCxx, in the solution. Make it an empty project with no precompiled header.
 Add a new header file, e.g., TestTest.h, to the Header Files of the project.
 Open the new .h file and add some CxxTests, e.g.,
#include &quot;cxxtest/TestSuite.h&quot;
 
class MyTestSuite : public CxxTest::TestSuite 
{
public:
    void testAddition( void )
    {
       TS_ASSERT( 1 + 1 &amp;gt; 1 );
       TS_ASSERT_EQUALS( 1 + 1, 2 );
    }

    void testMultiplication( void )
    {
       TS_ASSERT_EQUALS( 2 * 2, 5 );
    }
};

 Right click on the .h file and select the Property page.
 In the property page go to the Custom Build Step section. Select the Command Line entry and add the appropriate cxxtestgen line, such as
python path/to/cxxtest/cxxtestgen.py --runner=ParenPrinter 
                                        -o TestTest.cpp TestTest.h
Adjust as needed for your python/perl and cxxtest setup. Be sure to use the &quot;--runner=ParenPrinter&quot; option, as this will produce messages that are clickable in the output window
 Put your .cpp filename (from the -o in cxxtestgen) in the Outputs list. For extra credit, add something pithy to the Description line, like ...</description>
	<language>en</language>
	<copyright>2006-2008, Rod Morison Software</copyright>
	<managingEditor>technotes@morison.biz</managingEditor>
	<lastBuildDate>Sun, 01 Aug 2010 09:15:12 GMT</lastBuildDate>
	<generator>Yet Another Community System</generator>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>70</ttl>

	<item>
		<title>Gail:This article describes exactly what I am trying to do.
... (127 words to read) </title>
		<link>http://morison.biz/technotes/comments/4</link>
		<guid isPermaLink="true">http://morison.biz/technotes/comments/4</guid>
		<description>This article describes exactly what I am trying to do.
The problem is that in the post-build step, the tests do not appear to run inside VS.NET 2003. Not only that, I cannot get any output from the tests to appear in the IDE output window whether or not the test fails. The pre-build works fine and it generates an executable that works properly when run in a cmd shell - that is the output from the cxxtest suite is shown properly.



I wrote two simple tests one of which fails: TS_FAIL(&quot;ERROR&quot;). 
The other always passes: TS_ASSERT(1 == 1);



My pre-build command is:
cxxtestgen.pl -o MyTest.cpp --runner=ParenPrinter MyTest.h



My post-build command is 3 lines:
echo &quot;Run test&quot;



MyTest.exe



echo &quot;Test Completed&quot;



The echoes work fine. Thank you Microsoft   



If you have any ideas I would be grateful for the help!
Thanks.</description>
		<body xmlns="http://www.w3.org/1999/xhtml">This article describes exactly what I am trying to do.
The problem is that in the post-build step, the tests do not appear to run inside VS.NET 2003. Not only that, I cannot get any output from the tests to appear in the IDE output window whether or not the test fails. The pre-build works fine and it generates an executable that works properly when run in a cmd shell - that is the output from the cxxtest suite is shown properly.<br />
<br />
I wrote two simple tests one of which fails: TS_FAIL("ERROR"). 
The other always passes: TS_ASSERT(1 == 1);<br />
<br />
My pre-build command is:
cxxtestgen.pl -o MyTest.cpp --runner=ParenPrinter MyTest.h<br />
<br />
My post-build command is 3 lines:
echo "Run test"<br />
<br />
MyTest.exe<br />
<br />
echo "Test Completed"<br />
<br />
The echoes work fine. Thank you Microsoft  <img src="http://morison.biz/technotes/skins/images/smileys/angry.gif" alt="" /> <br />
<br />
If you have any ideas I would be grateful for the help!
Thanks.</body>
		<dc:creator>Gail</dc:creator>
		<category>CxxTest setup for the Visual Studio IDE</category>
		<pubDate>Fri, 05 Sep 2008 10:15:11 GMT</pubDate>
	</item>

	<item>
		<title>Kfitch:On a related note, CxxTest has a new home:
http://cxxtest....</title>
		<link>http://morison.biz/technotes/comments/5</link>
		<guid isPermaLink="true">http://morison.biz/technotes/comments/5</guid>
		<description>On a related note, CxxTest has a new home:
cxxtest.tigris.org



Also, there is a Wiki for CxxTest at:
cxxtest.com



And here is a link to a slightly updated user's guide</description>
		<body xmlns="http://www.w3.org/1999/xhtml">On a related note, CxxTest has a new home:
<a href="http://cxxtest.tigris.org" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">cxxtest.tigris.org</a><br />
<br />
Also, there is a Wiki for CxxTest at:
<a href="http://cxxtest.com" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">cxxtest.com</a><br />
<br />
And here is a link to a <a href="http://cxxtest.com/guide.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">slightly updated user's guide</a></body>
		<dc:creator>kfitch</dc:creator>
		<category>CxxTest setup for the Visual Studio IDE</category>
		<pubDate>Tue, 09 Sep 2008 09:54:23 GMT</pubDate>
	</item>

	<item>
		<title>Gail:I finally resolved the issues I had when trying to ... (291 words to read) </title>
		<link>http://morison.biz/technotes/comments/6</link>
		<guid isPermaLink="true">http://morison.biz/technotes/comments/6</guid>
		<description>I finally resolved the issues I had when trying to call runner.exe within the Visual Studio 2003 environment using a Post-Build Event. No output would show in the Build window (runner.exe was built using --runner=ParenPrinter).



The problem arose because my runner.exe depends on some external DLLs.  The WINDOWS DLL runtime search order is: the parent directory of the executable, some system directories, and then the directories listed in %PATH%. I did not realize that Visual Studio does NOT use environment variables, like %PATH%, added or modified after VS has been installed!!!! It should be noted however that when running your program in the Debugger from within the IDE, it DOES use updates to the environment in place when the IDE is started. Even if you start devenv.exe from a shell, as opposed to a shortcut, the Post-Build event has no knowledge of changes to your environment that were made after installation. Only the geniuses at Microsoft can explain this behavior.



What this means is that external DLLs that are needed to run your test, and which you added to your PATH variable, are not available when the Post-Build event executes. 



There are 2 solutions. The better option is to add the necessary env vars and update the path in a batch file that calls runner.exe. For example, place the following in a postbuild.cmd file located with your source code and call it in the Post-Build event:



set QTDIR=c:\someplace\qt\WINDOWS
path = %PATH%;%QTDIR%\debug\lib
runner.exe



The other solution is to add an entry to the VS Tools-&gt;Options-&gt;Projects-&gt;C++ Directories dialog when the the &quot;Show Directories for:&quot; dialog says &quot;Executable Files&quot;. To match the above batch script, the entry would be c:\someplace\qt\WINDOWS\debug\lib.



I prefer the former since what is going on visible and explicit instead of being hidden in one of the dozens of dialogs in the IDE.</description>
		<body xmlns="http://www.w3.org/1999/xhtml">I finally resolved the issues I had when trying to call runner.exe within the Visual Studio 2003 environment using a Post-Build Event. No output would show in the Build window (runner.exe was built using --runner=ParenPrinter).<br />
<br />
The problem arose because my runner.exe depends on some external DLLs.  The WINDOWS DLL runtime search order is: the parent directory of the executable, some system directories, and then the directories listed in %PATH%. I did not realize that Visual Studio does NOT use environment variables, like %PATH%, added or modified after VS has been installed!!!! It should be noted however that when running your program in the Debugger from within the IDE, it DOES use updates to the environment in place when the IDE is started. Even if you start devenv.exe from a shell, as opposed to a shortcut, the Post-Build event has no knowledge of changes to your environment that were made after installation. Only the geniuses at Microsoft can explain this behavior.<br />
<br />
What this means is that external DLLs that are needed to run your test, and which you added to your PATH variable, are not available when the Post-Build event executes. <br />
<br />
There are 2 solutions. The better option is to add the necessary env vars and update the path in a batch file that calls runner.exe. For example, place the following in a postbuild.cmd file located with your source code and call it in the Post-Build event:<br />
<br />
set QTDIR=c:\someplace\qt\WINDOWS
path = %PATH%;%QTDIR%\debug\lib
runner.exe<br />
<br />
The other solution is to add an entry to the VS Tools->Options->Projects->C++ Directories dialog when the the "Show Directories for:" dialog says "Executable Files". To match the above batch script, the entry would be c:\someplace\qt\WINDOWS\debug\lib.<br />
<br />
I prefer the former since what is going on visible and explicit instead of being hidden in one of the dozens of dialogs in the IDE.</body>
		<dc:creator>Gail</dc:creator>
		<category>CxxTest setup for the Visual Studio IDE</category>
		<pubDate>Sat, 20 Sep 2008 08:39:20 GMT</pubDate>
	</item>

	<item>
		<title>Kupps:Good setup!  Mine works fine until I add a second ...</title>
		<link>http://morison.biz/technotes/comments/13</link>
		<guid isPermaLink="true">http://morison.biz/technotes/comments/13</guid>
		<description>Good setup!  Mine works fine until I add a second header file to the project...



Should I be changing the settings on the second header file's Custom Build Step...?</description>
		<body xmlns="http://www.w3.org/1999/xhtml">Good setup!  Mine works fine until I add a second header file to the project...<br />
<br />
Should I be changing the settings on the second header file's Custom Build Step...?</body>
		<dc:creator>Kupps</dc:creator>
		<category>CxxTest setup for the Visual Studio IDE</category>
		<pubDate>Thu, 12 Nov 2009 18:49:06 GMT</pubDate>
	</item>

</channel>
</rss>