简体   繁体   English

C++ CppUnitTestFramework 在构建后运行测试

[英]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.我想为我的 C++ 项目编写一些测试...因此我添加了一个新项目来编写测试。 (this is a class library type). (这是一个类库类型)。 I came up with a Solution using Microsoft::VisualStudio::CppUnitTestFramework .我想出了一个使用Microsoft::VisualStudio::CppUnitTestFramework的解决方案。 Somehow VS detects my tests marked with TEST_METHOD(...) macro and I'm able to execute them using Test Explorer. VS 以某种方式检测到我用TEST_METHOD(...)宏标记的测试,并且我能够使用测试资源管理器执行它们。

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.基本上我正在寻找一个 postbuild 命令来执行另一个项目的测试。 That shouldn't be so hard?那不应该那么难吗?

Thanks in advance提前致谢

From a Visual Studio Command Prompt, you run the command vstest.console.exe myTestProject.dll .从 Visual Studio 命令提示符运行命令vstest.console.exe myTestProject.dll Simply add this command to your post-build steps, and fail if it returns nonzero in ERRORLEVEL .只需将此命令添加到您的构建后步骤,如果它在ERRORLEVEL中返回非零值,则失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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