Skip to main content Help Control Panel

Rod Morison Software —  Technotes

Home «   R&D «   C++ «   CxxTest setup for the Visual Studio IDE «  

Discuss: CxxTest setup for the Visual Studio IDE

The CxxTest docs give a cumbersome, multi-project-with-makefile procedure for using CxxTest in Visual Studio. Here's something better
Gail on Sep. 5 2008
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("ERROR"). 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 "Run test"

MyTest.exe

echo "Test Completed"

The echoes work fine. Thank you Microsoft

If you have any ideas I would be grateful for the help! Thanks.
Kfitch on Sep. 9 2008
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
Gail on Sep. 20 2008
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->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.

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.
Kupps on Nov. 12 2009
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...?