Ignore unit test in your own VC ++ project

How to use a macro TEST_IGNORE()in native VC ++ unit test projects in Visual Studio 2015? I use [Ignore]in C #, but I obviously missed something in VC ++.

Here is what I tried, but the macro TEST_IGNORE()expands to invalid code (lots of "unexpected tokens" and "syntax error:" {'"errors ...)

TEST_CLASS(MyTests)
{
   public:
   TEST_IGNORE()
   TEST_METHOD(TestSomething)
   {
     /*Test code is here*/
   }
};
+4
source share
1 answer

Figured it out. You need a sandwich macro TEST_IGNORE()between BEGIN_TEST_METHOD_ATTRIBUTE(testName)andEND_TEST_METHOD_ATTRIBUTE()

So the above code becomes

TEST_CLASS(MyTests)
{
   public:
   BEGIN_TEST_METHOD_ATTRIBUTE(TestSomething)
     TEST_IGNORE()
   END_TEST_METHOD_ATTRIBUTE()
   TEST_METHOD(TestSomething)
   {
     /*Test code is here*/
   }
};
+4
source

Source: https://habr.com/ru/post/1652056/


All Articles