microsoft-cpp-unit-test

How to initialize test variables using Visual Studio CppUnitTestFramework

痞子三分冷 提交于 2021-02-10 17:54:47
问题 I'm writing a roboter controller class Controller in which I'm using a struct Axis for each of the 4 controllable motors. For each test I want to reset everything, so I created a pointer in the class which is changed to a new Controller before each test method. The initialisation works fine in TEST_METHOD_INITIALIZE, but once any TEST_METHOD is called the program seems reset the Axis pointers. Thanks for your help! Edit: After further analysis I have the theory, that the initialised Axis

How to initialize test variables using Visual Studio CppUnitTestFramework

别说谁变了你拦得住时间么 提交于 2021-02-10 17:53:13
问题 I'm writing a roboter controller class Controller in which I'm using a struct Axis for each of the 4 controllable motors. For each test I want to reset everything, so I created a pointer in the class which is changed to a new Controller before each test method. The initialisation works fine in TEST_METHOD_INITIALIZE, but once any TEST_METHOD is called the program seems reset the Axis pointers. Thanks for your help! Edit: After further analysis I have the theory, that the initialised Axis

C++ unit test testing, using template test class

夙愿已清 提交于 2020-01-23 06:22:26
问题 I’m doing some C++ test driven development. I have a set of classes the do the same thing e.g. same input gives same output (or should, that’s what I’m try to test). I’m using Visual Studio 2012’s CppUnitTestFramework. I wanted to create a templated test class, so I write the tests once, and can template in classes as needed however I cannot find a way to do this. My aim: /* two classes that do the same thing */ class Class1 { int method() { return 1; } }; class Class2 { int method() { return

How to use Google Mock with CppUnitTestFramework

人走茶凉 提交于 2019-12-11 05:17:58
问题 TL;DR: You can use GMock to add mocking capability to your Microsoft native c++ unit tests. See my answer below for details. I want to start adding mocks to my existing set of native unit tests. The tests are written using Microsoft's CppUnitTestFramework framework, which doesn't have support for mocking. I don't really want to convert the entire test suite to another framework just to add a few mocks. Google's GMock framework seems to provide everything I need and the documentation suggests