Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run CMake unit tests with MSBuild.exe

Tags:

msbuild

cmake

Upon generating a Vistual Studio project from a CMake build file, CMake generates a solution with a sub-project called RUN_TESTS.vcproj that runs all unit tests as a post build action.

How can you invoke the RUN_TESTS from the command prompt using msbuild.exe?

Running msbuild RUN_TESTS.vcproj from the build directory does not work.

Under UNIX you would do a simple make test for Makefiles generated by CMake.

like image 378
sakra Avatar asked Oct 31 '10 21:10

sakra


People also ask

Does MSBuild run unit tests?

xUnit.net includes a runner which can be used from your MSBuild scripts to run unit tests. The runner is contained in the NuGet package xunit.

How to use CTest in CMake?

With -V , CTest will print out the command line used to run the test, as well as any output from the test itself. The -V option can be used with any invocation of CTest to provide more verbose output. The -N option is useful if you want to see what tests CTest would run without actually running them.

How do I run a specific test on CTest?

To run a single test and see how it is processed, invoke ctest from the command line providing the following arguments: Run single tst: -R <test-name> Enable verbose output: -VV.


1 Answers

There seems to be no way to run the tests through MSBuild.exe. You can invoke the tests with the executable ctest.exe which is part of the CMake installation:

ctest -C "Debug"

This will run the tests associated with the project's "Debug" configuration.

like image 97
sakra Avatar answered Sep 21 '22 19:09

sakra