0

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

  • I'm not sure about the specific unit testing framework you are using, but you can set-up post-build steps in dev-studio and point it towards any unit test executables. If your unit tests do not produce executable outputs, then you can write a script which invokes them and then call the script from dev-studio. – Mansoor Apr 11 at 14:30
  • @Mansoor thanks for your reply. My test projets output is one .dll, one .exp, one .ilk, one .lib and one .pdb file. So I guess I don't have an executable. How would I invoke my tests from a script? – user3292642 Apr 11 at 14:39
  • When you run if from test explorer, how is it being invoked? My guess would be there is an exe somewhere which is dynamically binding to the unit test DLLS you are producing. Maybe if you turn on diagnostic logging (Tools-Options->Builds and Runs->Logging) whilst running your unit tests, it will tell you how it is being run. Then you may be able to copy that command line right into your post-build steps. – Mansoor Apr 11 at 14:53
  • As an alternative, you could use GoogleTest which uses a similar syntax but produces executable outputs for each unit project. – Mansoor Apr 11 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.