Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building and running C++ unit tests in Visual Studio (TDD)

I have a large project for which I am attempting to use TDD. I am using Tut as my test framework, which has its flaws but is sufficient for what I need.

I need to exploit link time test seams, each test must be in its own executable. The project for this executable then launches itself as a post build step.

Unfortunately, this means that my Visual Studio Sln is filling up with tests, which is not scalable and also hides the actual important projects.

Does anyone know of a better way of running these tests? Is it possible to hide projects from a build and yet still have them build?

like image 613
Dave Hillier Avatar asked Nov 03 '08 11:11

Dave Hillier


1 Answers

"Is it possible to hide projects from a build and yet still have them build?"

You can make separate solution for test cases. Then you can set up post build step of your main projects. This post-build should build tests-projects via separate solution and run them. Building test-projects should be done via command line (see e.g. here for details).

If you need to link your unit tests with some lib-s from main projects, you can use

#pragma comment(lib, "libname")

See this MSDN page for details.

like image 57
sergtk Avatar answered Nov 16 '22 22:11

sergtk