简体   繁体   中英

C++ CppUnitTestFramework Run tests after build

I wanted to write some tests for my C++ project... Therefore I added a new project to write the test. (this is a class library type). I came up with a Solution using Microsoft::VisualStudio::CppUnitTestFramework . Somehow VS detects my tests marked with TEST_METHOD(...) macro and I'm able to execute them using Test Explorer.

So far so good... but now of course I want the tests to be executed automatically after each Build of my Solution... I thought there should be plenty of hits when I google this, but I did not find anything. Basically I'm looking for a postbuild command to execute the tests of another project. That shouldn't be so hard?

Thanks in advance

From a Visual Studio Command Prompt, you run the command vstest.console.exe myTestProject.dll . Simply add this command to your post-build steps, and fail if it returns nonzero in ERRORLEVEL .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM