[CMake] CTest integration in Visual Studio TestExplorer

Stuermer, Michael SP/HZA-ZSEP michael.stuermer at schaeffler.com
Thu Feb 4 10:27:16 EST 2016


Hi Máté,

thanks for trying the extension!

Some questions before going more into details:

-          do you have a CTestTestfile.cmake in your build root i.e. where the.sln file is you have opened with Visual Studio?

-          do you have a RUN_TESTS target/project in your visual studio solution? It could be in the “CMakePredefinedTargets” folder…

The basic concept of test discovery for the plugin is, to look for a CTestTestfile.cmake file in the same folder where the .sln file is. From there all CTestTestfile.cmake files are searched recursively and all tests which are defined by add_test() within the files are added to the test list.

There are some debug logging lines in the plugin, but I deactivated them for now. Unfortunately there is no option-page where you can switch the logging on/off (should move that to the top of the feature list). You could get the sources from github, enable logging, build your custom version and see what message you get.

The changes would be in “CTestExecutor.cs” (line 27) and “CTestDiscoverer.cs” (line 29). Change the line

public bool EnableLogging { get; set; } = false;

to

public bool EnableLogging { get; set; } = true;

further comments inline.

From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Nagy-Egri Máté Ferenc via CMake
Sent: Thursday, February 04, 2016 3:33 PM
To: cmake at cmake.org
Subject: Re: [CMake] CTest integration in Visual Studio TestExplorer


Hi Michael,

first of all, let me congratulate you on the integration. Great stuff and much apreciated.

I gave your add-in a spin, however it fails to find my unit tests. I set the output directory globally in the top-level CMakeLists.txt file as


set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Build_Root}/bin/${Configuration_Name})

[>] this should be perfectly OK, ctest should take care for itself where to find the binaries to execute when testing.

inside my unit-tests’ file I have entries such as

# Adding library target for build
add_executable (STL-Test1-RK4 ${STL_Test1_RK4_BUILD})

…

# Add CTest entry
add_test( ${PROJECT_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/STL-Test1-RK4 )

[>] what do you mean by „unit-test file”? Is it just another CMakeLists.txt or cmake script in your cmake script tree? or is this some script you run using ctest? I am not familiar with the ctest scripting options and I am pretty sure this is not supported by the extension right now. It is mainly thought to provide the tests which are executed by the RUN_TESTS target within the test explorer and allow more comfortable separate test running from within VS.

I have configured my build to use VS2015 Win64 platform. Because the default is to look for x86 targets, I changed the default test platform to be x64 within VS, but it still won’t find my tests. Could you give some directions what might I be doing wrong?

[>] AFAIK you don’t have to switch anything here to discover ctest tests. The tests are discovered from the CTestTestfile.cmake files, there is no checking for platform or bitness done.


Cheers,
Máté


Feladó: Stuermer, Michael SP/HZA-ZSEP<mailto:michael.stuermer at schaeffler.com>
Elküldve: 2016. január 22., péntek 12:37
Címzett: cmake at cmake.org<mailto:cmake at cmake.org>
Tárgy: [CMake] CTest integration in Visual Studio TestExplorer

Hello everyone,

picking up the line from Tobias from around a year ago I changed a few things in the ctest unittest adapter. It now works for both Visual Studio 2013 and 2015. 2012 is supported in general but I didn't try it (means: I can install it). Merging and pull request for original version will follow (as soon as there is time), but I would be really happy if some developers from the community could comment on the current state and give some feedback.

I tested it so far with the CMake build and tests and discovering and executing the whole lot of 400+ tests runs well so far. Let me know what could/should be improved.

You can download the latest version of the extension here:

https://github.com/micst/CTestTestAdapter/blob/micst/CTestTestAdapter.vsix

Check the sources on github here:

https://github.com/micst/CTestTestAdapter

best regards,
Michael


-----Original Message-----
From: Tobias Becker [mailto:becker.tobi at gmail.com]
Sent: Saturday, November 22, 2014 11:35 PM
Subject: [CMake] CTest integration in Visual Studio TestExplorer

So I tried my luck with creating an extension for Visual Studio that allows you to use the Test Explorer to discover and run your CTests.  You can download it in the visual studio gallery. Read about it on http://thetoeb.de/2014/11/22/ctest-integration-visualstudio/ .

I'd be happy if anyone wanted to give me feedback or contribute on https://github.com/toeb/CTestTestAdapter ;)

Sorry for the shameless plug (but hey - its free)


Kind Regards,

Tobias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141122/0a27b2b7/attachment.html>

--

Powered by www.kitware.com<http://www.kitware.com>

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160204/aa497ba2/attachment-0001.html>


More information about the CMake mailing list